Rails route: adding helpers methods
-
30-09-2022 - |
Question
I am coding an API in rails, and the following scheme appears multiple times in my routes.rb: (The goal is to link existing devices resource to users one.)
resources 'devices', controller: 'users_devices', only: [ 'index', 'destroy' ] do
post on: :member, action: 'create'
end
I would like to have a "route extension" that would allow me to do this:
relation 'devices', controller: 'users_devices'
Much more readable and since I have 5 times this same 'boiler plate' code, it would simplify the routes.rb
But... How can i code this "relation" method ?
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow