1

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 .

2
  • Do you just want to add or modify a method or do you want to do a more fundamental change? Commented 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 else Commented Jun 4, 2012 at 19:25

2 Answers 2

9

Fork it on github, make the changes and point your gemfile to the forked repo like so:

gem "contact-us", :git => "git://github.com/eqbal/contact-us.git"
Sign up to request clarification or add additional context in comments.

Comments

3

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.