Reputation: 962
Why can I not get my button_to to specify the create action of my controller rather than show
I have tried numerous times to add :action => "create" and other such things to the button_to parameters
<%= button_to "subscribe", subscription_path(feed_url: @feed.feed_url)%>
do I need to specify a create route in my routes.rb? if so how should I go about that?
When used the way that line is, I get this error on load:
Routing Error
No route matches {:action=>"show", :controller=>"subscriptions", :feed_url=>"http://foo.com/rss"}
in routes.rb I have this as the only reference to subscriptions.
resource :subscriptions
Upvotes: 0
Views: 3941
Reputation: 239521
You need to use subscriptons_path
, not subscription_path
.
subscription_path
is for showing a specific subscription.
subscriptions_path
is for showing all subscriptions (via a GET request) or creating new subscriptions (via a POST request).
<%= button_to "subscribe", subscriptions_path(feed_url: @feed.feed_url, :method => :post)%>
Upvotes: 4