Thursday, March 4, 2010

Rails 3 notes

JQuery:

Grab the jQuery driver at http://github.com/rails/jquery-ujs and put it in your javascripts directory. Include the file in the layout.

http://joshhuckabee.com/jquery-rails-3

Forms:

Rails requires an authenticity token to do form posts back to the server. This helps protect your site against CSRF attacks. In order to handle this requirement the driver looks for two meta tags that must be defined in your page's head.

csrf_meta_tag
Routing:

Old

link_to :controller => 'user_sessions', :action => 'destroy'
New

# Route
match '/log' => "user_sessions#destroy", :as => :logout

# View
link_to 'Logout', '/logout'

No comments:

Blog Archive