Search code examples
ruby-on-railsruby-on-rails-3inheritancedevisemixins

Inherit from multiple controllers.


Im using a Rails engine as a cms. It all works fine. Im adding devise to this.

My generated devise controllers inherit from Devise::SessionsController. But there are some filters that are run from another controller in the engine that wont run in this case. A lot of the site relies on these filters being run. Of course I could just duplicate them, but thats bad juju.

So my Question is: How can I make one controller run the filters from another? I would prefer not to edit either of the gems.


Solution

  • Multiple inheritance is not supported in Ruby. I think extracting the filters into a module and mixing them in would be the cleanest solution.

    See for example: http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html