Reputation: 205
I am attempting to create an object by passing it three parameters via a button click, but I can't get the routing to work. The three parameters are being passed by clicking a button on the view. Here is the code for my button:
<%= button_to "Create Object!", object_path(@email, @name, @size), method: :post %>
I am attempting to use the generic POST route to create a new object.
What needs to be adjusted? Do I need to write a custom route?
Upvotes: 1
Views: 391
Reputation: 1466
You need to pass it via key value pair as shown here.
<%= button_to "Create Object!", object_path(email: @email, name: @name, size: @size), method: :post %>
After this you can get those values via params in controller.
Upvotes: 1