I have a regular users model with address columns. But when a person attempts to register with email and password he receives the error: zip address and town cannot be blank. All you should need to register is email and password. How do I fix user creation ?
User Model:
class User < ActiveRecord::Base
attr_accessible :zip, :state, :town, :address, :email, :password, :password_confirmation,
attr_accessor :password
validates_confirmation_of :password
validates :email, presence: true, format: { with: VALID_E_REGEX }, uniqueness: { case_sensitive: false }
validates :password, presence: true, format:{ with: VALID_P_REGEX }, if: proc{ password_salt.blank? || password_hash.blank? }
validates :zip, format: { with: VALID_ZIP_REGEX }
validates :address, length: { minimum: 5 }
validates :town, length: { minimum: 4 }
end
User controller:
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to root_url, :notice => "Signed up!"
else
render "new"
end
end
end
Error:
!! #<ActiveRecord::RecordInvalid: Validation failed: Phone number is invalid, Zip is invalid, Address is too short (minimum is 5 characters), Town is too short (minimum is 4 characters)>