Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override a Rails Engine controller action

i'm using a Rails engine, but i need to customize some controllers actions.

I actually forked the engine, and implementing those customizations into my own fork, but i was wondering if there is an official way in Rails Engines to override and customize controllers.

like image 530
Marco Borromeo Avatar asked May 21 '10 09:05

Marco Borromeo


Video Answer


1 Answers

Just define a controller with the same name in your own app\controllers folder, and it will be found first. That way you can easily customize it.

Please note: because it is found first, you replace the entire controller from the engine. This could be exactly what you want. In some cases, you just want to adjust a little, then it is much better to reopen the class, and only redefine what is needed.

Examples to do is can be found here: http://edgeguides.rubyonrails.org/engines.html#overriding-models-and-controllers

like image 59
nathanvda Avatar answered Oct 12 '22 06:10

nathanvda