Rails button_to error with path does not exist for path that exists

Writing my first, very simple Rails application, a simple application to track the work of one of our departments. The generated index page for people has a link to it to add a new person. I tried changing this to button_to, and he did not say that the path / people / new does not exist, although obviously this is happening since link_to goes to the same place.

I am using Rails 3 / Ruby 1.9.2. I have this code on the /app/views/people/index.html.erb page:

<%= link_to 'New Person', new_person_path %>
<%= button_to "New", :controller => "people", :action => "new" %>

Link link_to works. Button button_to failed:

Routing error No route matches "/ people / new"

Also tried just

<%= button_to 'New Person', new_person_path %>

The same mistakes. Odd

+5
4

button_to post. :method => :get. link_to .

+9

, :)

link_to GET , button_to POST. POST, , GET.

button_to, :method => :get , GET.

+3

config/routes.rb? , routes.rb:

resources :people

guide , .

0

Is your button_toinside the form? button_tocreates its own form, so this would create the form inside the form and would probably disrupt routing.

0
source

All Articles