What's Ruby
A programming language
What's Rails
Initially developed by David Heinemeier Hansson, out of his
work on Base camp, a project management system
It is a framework of scripts in ruby that provide for rapid
development of web applications, esp those with a database
back end
Rails can build the skeleton of an application, including the
database tables, in just a few commands
Ruby
Syntax
Ruby is largely and loosely based on perl (hence the name,
according to lore)
Completely object oriented
Object Oriented
Truly
Not a prototyping language like javascript
Nor a procedural language with OOP bolted on
Classes
A class is a kind of master object
Can contain constants and methods
Instances of object can be created from a class, inheriting the
traits of the class
A simple class
class Cat
end
(but this class doesn't do or mean anything)
cat class
Several concepts
creating a new cat
add a method
calling the method
Access Control
Variables
Arrays
Hashes
conditional
Rails
Model
Contains the data of the application
Transient
Stored (eg Database)
Enforces "business" rules of the application
Attributes
Work flow
Views
Provides the user interface
Dynamic content rendered through templates
Three major types
Ruby code in erb (embedded ruby) templates
xml.builder templates
rjs templates (for javascript, and thus ajax)
Controllers
Action Pack
Since views and controllers interact so tightly, in rails they are
combined in Action Pack
Action pack breaks a web request into view components and
controller compoents
So an action usually involves a controller request to create,
read, update, or delete (CRUD) some part of the model,
followed by a view request to render a page
Several concepts
Processing URLs
The View
Creating a basic site
Directory Structure
Generating a database site