Been staring at this problem for a while now. Here’s the error I’m getting when I try to view the page.
No route matches {:action=>"confirm", :controller=>"locations"}
This is what I have in the view.
<%= form_for(@location, :url => { :action => :confirm }) do |f| %>
<% end %>
And I think my routes file is set up correctly.
Finder::Application.routes.draw do
resources :locations do
member do
post :confirm
end
end
root :to => 'locations/index'
end
Any ideas?
Updated:
Ran rake routes and get what I think is correct.
confirm_location POST /locations/:id/confirm(.:format) {:action=>"confirm", :controller=>"locations"}
You can debug your routes easily in the future by running
$ rake routesand looking at the output. 😉I think what is happening is that your
post :confirmisn’t registering the route you’re expecting. In the guides,matchand it’s brethren accept a string as a URL segment like so:Note that “confirm” is now a string instead of a symbol.
If this doesn’t help, run
$ rake routesand tack the output onto your question.Update
After seeing your rake output, I think that you just need to specify the POST method on your
form_for:You can also make this more readable using that helper method that Rails defines: