say
say

Reputation: 2655

How to change the controller path of a link in rails 3?

How do I get:

<%= link_to 'Back', originalcontrollers_path %>

to be:

<%= link_to 'Back', modifiedcontrollers_path %>

I already have my route updated with:

get "modifiedcontrollers", :to => "originalcontrollers#index"

So the "/modifiedcontroller" url works the same as "/originalcontroller". When creating links I need it to point to the new url. How would I do this?

Upvotes: 0

Views: 409

Answers (1)

fl00r
fl00r

Reputation: 83680

I am not sure I understand you, but try this:

get "modifiedcontrollers", :to => "originalcontrollers#index", :as => :modifiedcontrollers
get "modifiedcontrollers/new", :to => "originalcontrollers#new", :as => :new_modifiedcontroller
...

so if you need all stack of routes:

resources :modifiedcontrollers, :controller => :originalcontrollers

so now this will work as expected

<%= link_to 'Back', modifiedcontrollers_path %>

Upvotes: 2

Related Questions