[LRUG] Parameterising a Rails 3 controller mixin

Andrew Stewart boss at airbladesoftware.com
Tue Oct 4 06:58:14 PDT 2011


On 4 Oct 2011, at 15:27, Graham Ashton wrote:
> If you want to configure an engine, you could allow the user of the engine to do it in an initializer.
> 
> Rails::Engine inherits from Rails::Railtie. Have a look at the Configuration section on here:
> 
> http://edgeapi.rubyonrails.org/classes/Rails/Railtie.html
> 
> It might not really fit what you're trying to do, but I thought it worth mentioning just in case.

In fact that is how the engine is configured.  Here it is:

https://github.com/airblade/quo_vadis/blob/master/config/initializers/quo_vadis.rb

And the point where the controller mixin is mixed in:

https://github.com/airblade/quo_vadis/blob/master/lib/quo_vadis/engine.rb

> To test it you could skip the config setting when Rails.env is test and call the config block inside your test file.

But by then the controller would already have the wrong methods mixed in...

-- Andy


More information about the Chat mailing list