Forum: Ruby Not able to access session data in before_filter

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cc6ae9862e93740637dbbea00b680616?d=identicon&s=25 Preethi Sivakumar (preethi)
on 2009-02-09 10:41
Hi,

I've a session data that is generated when a user logs in.
I'm trying to access that session data, in before_filter, in a different
controller for passing parameter to the before_filter function.

before_filter :only => [:index] do |obj|
    user = session[:user]
    has_permission_in_any(user.id,component_id,permission_id,user.communities)
end

But i'm not able to do that. What might be the reason?
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-02-09 12:09
Preethi Sivakumar wrote:
> Hi,
>
> I've a session data that is generated when a user logs in.
> I'm trying to access that session data, in before_filter, in a different
> controller for passing parameter to the before_filter function.
>
> before_filter :only => [:index] do |obj|
>     user = session[:user]
>     has_permission_in_any(user.id,component_id,permission_id,user.communities)
> end
>
> But i'm not able to do that. What might be the reason?

As a guess, because you didn't actually say so, you're asking about the
Rails web application framework.

You'd best ask this question on a Rails mailing list. Here you've found
the list for the Ruby programming language (which Rails just happens to
be written in).
Cc6ae9862e93740637dbbea00b680616?d=identicon&s=25 Preethi Sivakumar (preethi)
on 2009-02-09 12:32
Brian Candler wrote:
> Preethi Sivakumar wrote:
>> Hi,
>>
>> I've a session data that is generated when a user logs in.
>> I'm trying to access that session data, in before_filter, in a different
>> controller for passing parameter to the before_filter function.
>>
>> before_filter :only => [:index] do |obj|
>>     user = session[:user]
>>     has_permission_in_any(user.id,component_id,permission_id,user.communities)
>> end
>>
>> But i'm not able to do that. What might be the reason?
>
> As a guess, because you didn't actually say so, you're asking about the
> Rails web application framework.
>
> You'd best ask this question on a Rails mailing list. Here you've found
> the list for the Ruby programming language (which Rails just happens to
> be written in).


thanks for guiding me to the right path :)
This topic is locked and can not be replied to.