6. If blocks if something stuff elsif something_else Other stuffe else Other other stuff end
7. Ranges and symbols (1...80) is a range contains everything within it and can be iterated over. Colons start symbols which are minimal bits of data representing only themselves, often used as keys in hashes. :symbol
8. Rails Started 2004 Included in Mac OS X by default in 2006 Recently: twitter, ravelry etc.
11. Generators rails appname script/generate model/controller name script/generate migration migration
12. Scaffold generation Not really my first choice, but good for demonstrations and prototyping. script/generate scaffold Movie name:string description:text
13. Migrations Go up and down add_column :table, :name, type remove_column :table, :name
14. Routes Create restful routes for a controller map.resources :controller_name Make default page the index map.root :controller => 'movies', :action => 'index (may also need to delete index.html in public)
15. Adding Reviews script/generate scaffold Review rating:integer movie_id:integer content:text In movie model add has_many :reviews In review model add belongs_to :movie
16. Reviews New method in the controller needs an array of movies to be added to: @movies = Movies.all.collect { |movie| [movie.name, movie.id]} The view needs a select: <%= f.select(:movie, @movies) %>
17. Partials Major part of reusing code. In a view: <% render :partial => “/reviews/form” %> Create partials with file names like _form.html.erb
18. Displaying reviews on a film In show method of the movie controller add: @reviews = @movie.reviews (After setting @movie) In the view <% @reviews.each do |review| %> <%= render :partial => “review”, :locals => { :review => review } %> <% end %> Create the partial or even extract it from the default review show!
19. Other resources Rails Guides Agile web dev with rails book Railscasts Wellrailed google group Google