jriley88
jriley88

Reputation: 117

No Route Matches Rails 4

I generated a scaffold for Studio. Now am linking from Products view

<%= button_to 'Customize', new_studio_path %>

resources :studios is placed in routes.rb

I am still getting No route matches [POST] "/studios/new"

If someone could help me figure this out I would appreciate it tons.

Here is a gists of the files I am working with for this. https://gist.github.com/JRizzle88/7861628

Upvotes: 0

Views: 74

Answers (3)

benjaminjosephw
benjaminjosephw

Reputation: 4417

The rails convention would be to use link_to which will send a GET request:

<%= link_to 'Customize', new_studio_path %>

Upvotes: 1

BroiSatse
BroiSatse

Reputation: 44675

Button is sending a POST request, where your server expects a GET request for given url. You need to specify method on a button:

<%= button_to 'Customize', new_studio_path, method: :get %>

Upvotes: 2

Marek Lipka
Marek Lipka

Reputation: 51151

Button's default HTTP method is POST, what you need is method GET, so you need to specify this explicitly:

<%= button_to 'Customize', new_studio_path, method: :get %>

Upvotes: 2

Related Questions