of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase # This route can be invoked with purchase_url(:id => product.id) # Sample resource route (maps HTTP verbs to controller actions automatically): # resources :products # Sample resource route with options: # resources :products do # member do # get 'short' Monday, March 26, 12
root :to => 'welcome#index' # MORE INFORMATION # Run "rake routes" to see the routes available # http://guides.rubyonrails.org/routing.html end Monday, March 26, 12
for attributes with # attr_accessible :title, :body end module Blog class Application < Rails::Application # Block all model attributes from mass assignment # unless attr_accessible is used config.attributes_protected_by_default = true #... end end Monday, March 26, 12
attr_accessor name helper_method name private "#{name}=".to_sym end end end class ApplicationController < ActionController::Base protect_from_forgery include AttributeViewable end Monday, March 26, 12
system-level with rake • attr_accessible by default • Break logic from persistence • Eliminate instance vars from views Adventures on the Golden Path Jeff Casimir / Jumpstart Lab / @j3 Monday, March 26, 12