I'm using rails 3 with bundler, I installed a gem using bundler, now I need to modify the flow of the gem slightly by modifying the controller of the gem, how am I supposed to do so, i'm sure there is a command to install the files locally so I can modify it, I tried to override the controller by creating another controller with the same name but sounds not working .
-
Do you just want to add or modify a method or do you want to do a more fundamental change?DVG– DVG2012-06-04 19:21:12 +00:00Commented Jun 4, 2012 at 19:21
-
I installed a gem called contact-us , and I need to change the behavior of the controller there, if I can achieve this in anyway i would be happy by modifying the method or by anything elseEqbal– Eqbal2012-06-04 19:25:24 +00:00Commented Jun 4, 2012 at 19:25
Add a comment
|
2 Answers
You should just be able to make a controller, inherit from the gem controller and override the method behavior as you see fit
class MyController < ContactUs::ContactsController
def create
# my code that changes the behavior
end
end
And then you may have to tell your routes to go to your controller
resources :contacts,
:controller => 'my_controller'
1 Comment
Eqbal
Amazing, thanks for the help, it is exactly what i'm looking for, I guess the route supposed to be resources :contacts,:controller => 'my' in case u named the file my_controller