Set filter before_action for ActiveAdmin controller
activeadmin, ruby, ruby-on-rails, ruby-on-rails-3, ruby-on-rails-4
Solution
You can access the controller from within the `controller do ... end` DSL:
ActiveAdmin.register User do
before_action :set_product, only: [:show, :edit, :update, :destroy]
controller do
def set_product
@product = Product.find_by_name(params[:name])
end
end
end
Problem
I want to add before_action filter to ActiveAdmin controller. Could I do something like this: ``` before_action :set_product, only: [:show, :edit, :update, :destroy] private def set_product @product = Product.find_by_name(params[:name]) end ```