OK, so I had a bit more of a play. You'll still need to do this:
> controller = "#{options[:controller]}_controller".camelize.constantize
>
But if you create a file in config/initializers called "action_filtered.rb"
and put this in it:
class ActionController::Base
def self.action_filtered?(action_name, filter_name)
action_name = action_name.to_s
filter_chain.each do |filter|
if filter.method == filter_name
if filter.options[:only].respond_to?(:include?)
if filter.options[:only].include?(action_name)
return true
end
elsif filter.options[:except].respond_to?(:include?)
if !filter.options[:except].include?(action_name)
return true
end
else
return true
end
end
end
false
end
end
You'll then have a method on a controller so you can do this:
controller = "#{options[:controller]}_controller".camelize.constantize
login_required = controller.action_filtered?(options[:action], :
login_required)
And login_required will be a boolean value as to whether the login_required
filter is effective for that action.
You will probably want to wrap that up in to a method somewhere neater and
you'd need to consider that the user may already be logged in (in which case
you don't want the popup), but it may help you get started.
Cheers,
Andy
--
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.