Forum: Ruby on Rails RE: Passing a parameter to a before_filter method

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.
HOGANBP (Guest)
on 2005-12-07 21:52
(Received via mailing list)
Can you use the session to store the parameter so you don't have to pass
anything?
alisonrowland (Guest)
on 2005-12-08 14:32
(Received via mailing list)
Thanks for the replies. The lambda didn't want to work. I got a no
method error. That was with the called function in application.rb and
the before_filter call in another file, which was a sub-sub-class of
application.rb.

I ended up reorganizing my one or two bigger functions into three
really small functions, and got things working.

--Alison
ksruby (Guest)
on 2005-12-08 17:42
(Received via mailing list)
Actually I got the lambda version wrong. It should look like

before_filter lambda{|controller| controller.authorize("admin") }

Kent.
justin (Guest)
on 2005-12-08 18:23
(Received via mailing list)
Kent S. wrote:

>>the before_filter call in another file, which was a sub-sub-class of
>>application.rb.
>>
>>I ended up reorganizing my one or two bigger functions into three
>>really small functions, and got things working.

One other point - Rails is single threaded, so you can use class
variables or globals to hold state within the life of a single request.
I've seen this given as the answer to "how to make the current user
accessible to models".

regards

   Justin
This topic is locked and can not be replied to.