Search code examples
ruby-on-railsbefore-filter

Global before_filter in rails


I need to execute a method before certains actions in a rails app and apparently the right way to go is using a before_filter.

The before_filter works fine when a put the filter method in the controller, but I need to use this filter in all the controllers, and I don't think would be right repeat the filter code en each one of them. So, I moved the code to the application controller, but it stopped work.

I don't know if I'm calling it wrongly, I don't know. What is the right way to do this?

PD: I call the filter this way

:before_filter => :get_language

Solution

  • try before_filter not :before_filter (symbol)