Ruby on Rails

DOWNLOAD

.DOC  .PPT



Table of Contents



1. Introducing Ruby on Rails ...................................................................... 1
History ....................................................................................3
Development Principles ......................................................... 5
Convention Over Configuration .............................................5
Don’t Repeat Yourself .............................................................7
Agile Development ..................................................................7
Building the Example Web Application .................................. 9
What is digg? .......................................................................... 9
What Does All this Cost? ................................................................... 16


  1. Introducing Ruby ................................................................................. 51
Ruby is a Scripting Language ..................................................51
Compiled Languages ...............................................................52
Scripting Languages .................................................................52
The Great Performance Debate .............................................. 52
Ruby is an Object Oriented Language ......................................53
Reading and Writing Ruby Code ……………………………………………56
The Interactive Ruby Shell (irb) ................................................. 57
Interacting with Ruby Objects .................................................... 58
Punctuation in Ruby .................................................................. 60
Object Oriented Programming in Ruby ....................................... 63
Classes and Objects .................................................................63
Object-level Functionality ......................................................... 64
Class-level Functionality ......................................................... 68
Inheritance .............................................................................70
Return Values ........................................................................... 71
Standard Output ........................................................................71
Ruby Core Classes ......................................................................... 72
Arrays ................................................................................... 73
Hashes ....................................................................................... 74
Strings ....................................................................................... 76
Numerics ................................................................................... 77
Symbols ..................................................................................... 78
nil .............................................................................................. 79


4. Rails Revealed ..................................................................................... 89


Three Environments ........................................................................... 89
Database Configuration ..................................................................... 91
The Database Configuration File…………. ............................................ 91
Creating the Databases…….. .............................................................. 93
The Model-view-controller Architecture............................................ 94
MVC in Theory……….. ......................................................................... 95
MVC the Rails Way ……….................................................................... 96
ActiveRecord (the Model)………. ......................................................... 97
The ActionPack Module………. .......................................................... 103
Code Generation .............................................................................. 107
ActionMailer .................................................................................... 109
Testing and Debugging ..................................................................... 109
Testing ..................................................................................... 109
Debugging ............................................................................... 110
A GUI Tool for MySQL.. .................................................................... 111
  1. Ruby on Rails CheetSheet .....................................................................89
  2. Conclusion .................................................................89


What is Ruby on Rails?
The short—and fairly technical—answer is that Ruby on Rails (often abbreviated to Rails) is a full-stack web application framework, written in Ruby. However, depending on your previous programming experience (and your mastery of techno-jargon), that answer might not make a whole lot of sense to you. Besides, the Ruby on Rails movement really needs to be viewed in the context of web development in general if it is to be fully appreciated.
So, let me define a few of those terms, and give you a brief history lesson along the way. Then we’ll tackle the question of why learning Rails is one of the smartest things you could do for your career as a web developer.
A web application is a software application that’s accessed using a web browser over a network. In most cases, that network is the Internet, but it could also be a corporate intranet. A big buzz has sprung up around web applications recently, due mostly to the increased availability of broadband Internet access and the proliferation of faster desktop machines in people’s homes.
❑ A framework can be viewed as the foundation of a web application. It takes care of many of the low-level details that can become repetitive and boring to code, allowing the developer to focus on building the application’s functionality.


A framework gives the developer classes that implement common functions used in every web application, including:
database abstraction (ensuring that queries work regardless of whether the database is MySQL, Oracle, DB2, or something else)
templating (reusing presentational code throughout the application)
management of user sessions
generation of “clean” URLs


A framework also defines the architecture of an application—something that can be useful for those of us who constantly fret over which file is best stored in which folder.


In a sense, a framework is an application that has been started for you—and a well-designed one at that. The structure, plus the code that takes care of the boring stuff, has already been written, and it’s up to us to finish it off!


Full-stack refers to the extent of the functionality the Rails framework provides. You see, there are frameworks, and then there are frameworks. Some provide great functionality on the server, but leave you high and dry on the client side; others are terrific at enhancing the user experience on the client machine, but don’t extend to the business logic and database interactions on the server.


Ruby is an open source, object oriented scripting language that Yukihiro Matsumoto invented in the early 1990s. We’ll be learning both Ruby and Rails as we progress through the book (remember, Rails is written in Ruby).
Ruby makes programming flexible and intuitive, and with it, we can write code that’s readable by both humans and machines. Matsumoto clearly envisioned Ruby to be a programming language that would entail very little mental overhead for humans, which is why Ruby programmers tend to be happy programmmers. .

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.