Disable sessions for API

In your controller, put:

session :disabled => true

I think I found what you want. From the doc:

See the last example with :if and Proc.
params[:format] will give you the requested format, you can probably
play with it to disable session.

Hey Jake,

I would assume that the proc just has to return true or false indicating whether or not to create a new session.

so something along the lines of

session :off, :if => Proc.new {|r| r.parameters
[:format] == :api}

or something along those lines.


It’s the request object. One of these:


If you’re using the RESTful routes in edge rails, a request of posts/1.api will set :format to ‘api’ (as in the previous e-mail’s example). The route looks like this:

GET /posts/:id.:format/ {:controller=>“posts”, :action=>“show”}

It all depends on how you want your API to be accessed. It’s up to you.

For more session info, see here: