Rails 3 Named Routes - Calling different actions in the controller dynamically as a parameter with the same named route

StackOverflow https://stackoverflow.com/questions/10379358

Question

Say i have a controller with index and doesn't have any other RESTful actions. I want to call different actions as a parametr from the same controller which has a named route as follows.

Example,

I have TargetsController and i should be able to call

targets_path(any_action, params)

Can i call

resources :targets do 
  get :action_name, :on => :member 
end

on a controller that does not have the Restful actions

How do i write this in the routes.rb ? All the documentation i found did not talk about how the same route is called in the controller. Thanks for your help

Was it helpful?

Solution

Ended up doing it with url_for helper

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top