Form not displaying errors
Here is my user.rb file
class User < ApplicationRecord
has_secure_password
validates :email, presence: true, format: { with: /\A[\w.+-]+@\w+.\w+\z/, message: "must be a valid email address" }
end
Here is my registration controller.rb
class RegistrationController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
redirect_to root_path, notice: "Successfully created account"
else
render :new
end
end
private
def user_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
end
Finally here is my form
Sign Up
<%= form_with model: @user, url: sign_up_path, local: true do |form| %>
<% if @user.errors.any? %>
<% @user.errors.full_messages.each do |message| %>
<%= message %>
<% end %>
<% end %>
<%= form.label :email %>
<%= form.text_field :email, class: "form-control", placeholder: "chris@apple.com" %>
<%= form.label :password %>
<%= form.password_field :password, class: "form-control", placeholder: "password" %>
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, class: "form-control", placeholder: "password" %>
<%= form.submit %>
<% end %>