Reputation: 1
I have a SubscriptionSignupsController
def create
@subscription = SubscriptionSignup.new(subscription_params)
if @subscription.save
redirect_to @subscription
else
render 'new'
end
end
My routes.rb file contains
resources 'subscription_signups', only: [:create, :new]
when I'm calling localhost:3000/subscription_signups
I get
No route matches [GET] error
My view for new.hmtl.erb file we are using gazelle design systems as sass
<div class="SubscriptionSignup">
<div class="SubscriptionSignup-content">
<form class="simple_form Form Form--protectSubmit">
<div class="email-signup">
<%= simple_form_for @subscription, html: { class: "Form Form--protectSubmit" } do |f| %>
<div class="dr-FormField Form-inputWrapper">
<div class="gds-FormField-label">
<%= f.input :email, placeholder: "Email address"%>
<%= f.input :password, placeholder: "6 Characters Minimum"%>
<%= f.input :password_confirmation, placeholder: "Same as Password"%>
<%= f.input :name%>
<%= f.input :address_lane_1%>
<%= f.input :address_lane_2%>
<%= f.input :city%>
<div class="Form-InputGroup">
<%= f.label :state %>
<%= select_tag "state", options_for_select(us_states)%>
<%= f.input :zip%>
</div>
</label>
</div>
</div>
<%= f.button :submit, "Review Order", class: "gds-Button Form-button" %>
<% end %>
</div>
</form>
</div>
Upvotes: 0
Views: 61
Reputation: 10111
If you are using simple_form_for then you should be able to do something like this
url_for(:action => 'create', :controller => 'subscription'), :method => 'post' do |f| %>I hope that this helps you out
Upvotes: 0
Reputation: 2219
If @subscription.save
is successful, then your #create action will redirect to #show but you aren't defining the show action in your routes. You have 2 options (assuming the error is due to the #create action redirect to #show:
resources 'subscription_signups', only: [:create, :new, :show]
redirect_to @subscription
(the missing show route)Have a look at Rails routing documentation for more info.
Upvotes: 1