0
votes

From Rails Tutorial Ch 10.1.1,q2: https://www.railstutorial.org/book/updating_and_deleting_users

I've refactored my signup form and edit form from users#new and users#edit into a form partial:

<%= form_for(@user) do |f| %>

  <%= render 'shared/error_messages', object: @user %>

  <%= f.label :name %>
  <%= f.text_field :name, class: 'form-control' %>

  <%= f.label :email %>
  <%= f.email_field :email, class: 'form-control' %>

  <%= f.label :password %>
  <%= f.password_field :password, class: 'form-control' %>

  <%= f.label :password_confirmation, "Confirmation" %>
  <%= f.password_field :password_confirmation, class: 'form-control' %>

  <%= f.submit yield(:button_text), class: 'btn btn-primary' %>
<% end %>

And in users/new.html.erb and users/edit.html.erb, I simply add the code,

<%= render 'form' %>

Problem is, my users#create is routed to /signup

So how do I get the form in users/new.html.erb to route to signup_path?

I tried

<%= render 'form', url: signup_path %>

but doesn't seem to work?

1

1 Answers

1
votes

You need to provide url to form helper:

<%= form_for(@user, url: signup_path) do |f| %>