I’m building a website based on RoR, and using a third-party gem “devise”. I have used rake gems:unpack to unpack the “devise” to my “vendor/gems” directory. Now, I found the method “SessionsController.create” provided by “devise” is not fit my requirement, and I want to modify it.
But I don’t know what it is best way:
- just modify the method SessionsController.create” directly?
- create another SessionsController and override the “create” method?
Ruby has open classes, to you should always tend toward reopening and redefining the method(s) you need to, so reopening SessionsController and overriding the create method would be the way to go.
Editing the gem directly puts a maintenance burden on you and everyone else that has to touch the code in the future. Eventually someone is going to forget and update that gem.