I’m trying to contribute to an open source project and I need a controller to handle a couple of forms that need to be submitted in.
I created these controllers inside a directory inside the gem called app/controllers/gemname/my_controller.rb.
However, when I try to access the controller, it seems not to be loaded (I get a name error just as if I typed something like NonExistentController).
How do I load my controller with the gem?
Thanks!
Let’s assume your gem is called
MyGemand you have a controller calledSuperControllerthat you want to use in the app. Your controller should be defined as:and in your gem directory it should live at
app/controllers/my_gem/super_controller.rb(not under thelibfolder). Check out the source for Devise as they do the same thing.[Edit] You may learn something from A Guide To Starting Your Own Rails Engine Gem regarding your current project.