Conditional Sessions

I am new to rails but have been able to cobble together a pretty decent
storefront and taken it live. However, creating a lot of false
sessions. Tried to implement a check for user_agent. The problem is
that when I issue a “session :off”, I’m receiving a “wrong number of
arguments (1 for 0)”. Turning the session off under the application.rb
works fine but as soon as I try to move it to an action within the
controller it errors as in

def cookies_required
session :off

return unless request.cookies["_session_id"].to_s.blank?
session[:return_to] = request.request_uri
redirect_to(:controller => "store", :action => "cookies_test")
return false

end

Any suggestions would be appreciated.

Bud

On 21 Jul 2008, at 09:58, Bud Buckwell wrote:


def cookies_required
session :off

return unless request.cookies["_session_id"].to_s.blank?
session[:return_to] = request.request_uri
redirect_to(:controller => “store”, :action => “cookies_test”)
return false
end

You can’t do thus like that. If you want sessions on or off on a per
action basis you need something like

class SomeController < ApplicationController
session :off, :if => Proc.new {|request| … }
end

with your proc evaluating to true or false as appropriate
Fred

Fred - thanks for the pointer - all better

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs