Ruby on Rails Wednesday, November 25, 2015

Hi,

I need to access one variable in entire controller i.e it is accessible
to all actions in controller.

I had tried with session and class variable but for example

def create
document_id = get_document
@@document_id = session[:document_id] = document_id
end

def validate
if document_id == (@@document_id || session[:document_id])
true
else
false
end
end

it works some time , some time uninitialized constant error for class
variable and session token is null when I refresh the browser.

I know session variable stored in server side but when I request
multiple times it returns null value.

i am also using before filter for that task, but no use.

please suggest me.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0966b9f0c0a795189fe0c1c462218b79%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment