Rails can't find my route but it exists!
- by DJTripleThreat
Ok I have events that I want to publish/unpublish with an extra action (nonRESTful) I watched Ryan Bates' railscast on this: http://railscasts.com/episodes/35-custom-rest-actions and it got me most of the way. I think the problem is that my route is nested in an /admin section so even though when I run rake routes and get:
publish_admin_event PUT /admin/events/:id/publish(.:format) {:controller=>"event_services", :action=>"publish"}
This won't work in my /views/admin/index.html.erb file:
<%= link_to 'Publish', publish_admin_event(event), :method => :put %>
because it claims that path doesn't exist! And neither will this:
<%= link_to 'Publish', {:controller => :event_services, :action => :publish}, {:method => :put, :id => event} %>
and says that "No route matches {:controller=>"event_services", :action=>"publish"}"
so what gives? (And I've tried restarting my server so that isn't it.)
EDIT:
This DOES work:
<%= link_to 'Publish', "/admin/events/" + event.id.to_s + "/publish", :method => :put %>
But I'd rather NOT do this.