I've googled around enough to see that this is a common issue, but
haven't found a definitive answer on how to access a value from the
params hash in a before_filter. I'm currently trying this:

  before_filter :only => [:create, :update, :destroy] do |controller|
    controller.bounce_if_unauthorized params[:token]
  end

with the following in application_controller.rb:

  protected
  def bounce_if_unauthorized token
    puts token
    redirect_to root_path,
      :alert => 'You are not authorized.' unless token == 'abcde'
  end

but the equality is never true. Meanwhile, the verify method mentioned
at http://guides.rubyonrails.org/action_controller_overview.html#filters
is no longer listed in the API, so that's probably not the way to go
either.

How can I create a before_filter based on an element of the params
hash?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to