-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how can I create a before_filter #1108
Comments
Put it in a controller block. The code in a controller block is executed just as if it were inside a controller:
If you want to have the before filter run before all active admin controllers/actions, you can put it in the AA initializer, there is clear documentation in the file about how to do that. |
Thank you |
how can you access the object that you are updating. for instance a instance of Post |
Unless you called You could test this by: ActiveAdmin.register Post do
controller do
before_filter :my_filter, only: [:edit, :show]
private
def my_filter
Rails.logger.info "my post: '#{resource}'"
end
end
end |
Thanks @latortuga and @macfanatic. :) |
@casiodk use |
Hi,
How can I create a before_filter only for some actions?
Thank you
The text was updated successfully, but these errors were encountered: