a kung-fu movie, where a dozen bad-ass frameworks prepare to beat up the little newcomer only to be handed their asses in a variety of imaginative ways.” Nathan Torkington, O’Reilly Media
ipsum... 2 a blog post part II lorem ipsum... 3 a blog post part III lorem ipsum... Active Record Database tables map to Ruby objects and columns become instance variables with getter and setter methods. class Post < ActiveRecord::Base end @post = Post.find(1) puts @post.title a blog post part I posts table
but Rails comes standard with ERB which is just Ruby mixed into HTML. <ul> <% @posts.each do |post| %> <li><%= post.title %></li> <% end %> </ul> • a blog post part I • a blog post part II • a blog post part III posts.html.erb as seen in the browser
upon a request. Responsible for responding or directing web requests through an application. Typically requests data from a model and responds with a view. class PostsController < ApplicationController def index @posts = Post.all end end Gets all posts and renders the posts/index.html.erb view. How does it know?!
POST DELETE GET /posts => Returns all posts, usually maps to an index action GET /posts/123, usually maps to a show action => Returns a post with the ID of 123