Tech Tidbits - Ruby, Ruby On Rails, Merb, .Net, Javascript, jQuery, Ajax, CSS...and other random bits and pieces.

Saturday, April 26, 2008

will_paginate gem

While upgrading an old project to Rails 2.0.2 (and having trouble getting the will_paginate plugin to install), I discovered that there is a will_paginate gem:

Railscasts - will_paginate

Thursday, April 24, 2008

Rails - ActionController::InvalidAuthenticityToken

ActionController::InvalidAuthenticityToken in User#login

Showing user/login.html.erb where line #2 raised:

No :secret given to the #protect_from_forgery call.
Set that or use a session store capable of generating its
own keys (Cookie Session Store).

This happened after I switched from using the file system to a database for storing sessions (after uncommenting the line "config.action_controller.session_store = :active_record_store" in config/environment.rb).

Once you switch to database store, you'll need to comment the "protect_from_forgery" line in app/controllers/application.rb

# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
#protect_from_forgery # :secret => 'b3e36f40312f075ea2697fb85180e312'

Rails 2.0.2 - setup with functional tests

If you want to use setup with functional tests in Rails 2.0.2, you'll need to rename the setup method to setup_with_fixtures and call super before running your setup code:
def setup_with_fixtures
# Set up code here

About Me

My photo
Developer (Ruby on Rails, iOS), musician/composer, Buddhist, HSP, Vegan, Aspie.