kkelly18
kkelly18

Reputation: 518

RoR Routes Error: From a link_to built URL, route appears in rake routes

routes.rb

resources :project_associations, :only => [:update]

rake routes

project_association PUT    /project_associations/:id(.:format)  {:action=>"update", :controller=>"project_associations"}

ERB

<%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command])%>

Resulting HTML

<a href="/project_associations/2011?command=suspend">Suspend</a>

Click result: Routing Error No route matches "/project_associations/2011"

I kicked the server, same result

Thanks in advance for any assistance.

Upvotes: 3

Views: 149

Answers (1)

rdvdijk
rdvdijk

Reputation: 4398

Add this to the link_to: :method => :put.

So:

    <%= link_to membership_command[:text], project_association_path(membership_command[:id], :command => membership_command[:command]), :method => :put %>

Upvotes: 2

Related Questions