I created a user registration page. When a user submits a form incorrectly, when a validation error is displayed, it does not display at the same URL.
The registration form is located at this URL:
http:
I added the following routes for the registration page:
resources :users
match '/signup', to: 'users#new', via: 'get'
When I submit the form, a model confirmation appears, but the URL is redirected to:
http:
I want the user to stay at the same URL after submitting the form.
http:
This is my controller code:
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
else
render 'new'
end
end
This is the start of my form tag:
<%= form_for @user, url: {action: "create"} do |f| %>
source
share