Forum: Ruby on Rails Returning a variable to 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.
F9bdba6e1c8a28664e99e9c8caaa05bd?d=identicon&s=25 Ami (Guest)
on 2008-10-26 00:58
(Received via mailing list)
I know its probably doesnt sound right, but I am trying to call a
before_filter method that will check whats the user role and then
based on that return a string / hash / array to the before_filter

something like this:

class MonqiClassesController < ResourceController::Base
  before_filter :check_user_access_level , grant_access

  def check_user_access_level

    if current_user.has_role?('staff')
     return grant_access = {:only  => :index}
    end
  end
end

i am planing on using case and then return the set of actions they can
preform

maybe there's a better way or someone already saw that somewhere

thanks
Ami
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-26 13:36
(Received via mailing list)
On 25 Oct 2008, at 23:57, Ami wrote:

>  def check_user_access_level
>
>    if current_user.has_role?('staff')
>     return grant_access = {:only  => :index}
>    end
>  end
> end
>
> i am planing on using case and then return the set of actions they can
> preform
>
Sound like you just want to set an instance variable.

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