Filter method should be inside controller
ActiveAdmin.register Event do
controller do
around_filter :my_filter
# lots of stuff here...
def my_filter
yield
end
end
end
Question
I'm trying to add an around_filter to a controller in ActiveAdmin. I get an undefined method error when I try to add the filter. Example:
ActiveAdmin.register Event do
controller do
around_filter :my_filter
def my_filter
yield
end
end
end
When I try it out, I get:
"undefined method `my_filter' for #<Admin::EventsController:0x0000010de3a798>"
My project is using Rails 3, if that's relevant. What am I missing here?
Update: This was due to a very silly syntax error. Rather than something like the above, I had misplaced my method definition, something like this:
ActiveAdmin.register Event do
controller do
around_filter :my_filter
# lots of stuff here...
end
def my_filter
yield
end
end
so I was declaring the around filter, but defining it outside the controller.
Solution
Filter method should be inside controller
ActiveAdmin.register Event do
controller do
around_filter :my_filter
# lots of stuff here...
def my_filter
yield
end
end
end