Answer the question
In order to leave comments, you need to log in
How to automatically load controller methods in routes?
Let's say I added a method to the controller with any name. How can I make this method appear automatically in the routes? To not have to always write
get 'controller_name/some_method', to: 'controller_name#some_method'
Answer the question
In order to leave comments, you need to log in
Technically
get 'controller_name/:action_name', to: 'controller_name#resolve'
def resolve
public_send(params[:action_name])
end
But, that's not the Rails way, you're doing something wrong. Rail explicitly asks to describe all the routes for a reason. There will hardly be a lot of them, but this gives information about the application and all kinds of helpers and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question