Rails 4 password confirmation ca

I look through one of the Rails lessons, during the user verification section, I always get an error message confirming that my password confirmations cannot be empty when editing / creating a user. I looked through the previous answers, and it looks like people were using attr_accessible, which was taken out of rails. I am full rails / web dev newb, so I'm not sure how to proceed. A look at HAML, sorry if this is a bad practice.

Model

class User < ActiveRecord::Base before_save { self.email = email.downcase } attr_accessor :name, :email validates_confirmation_of :password has_secure_password validates :name, presence: true, length:{ maximum: 16 } VALID_EMAIL_REGEX = /\A[\w+\-.] +@ [az\d\-.]+\.[az]+\z/i validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } validates :password, length: { minimum: 6 } has_one :profile has_many :posts end 

View

 = form_for(@user) do |f| - if @user.errors.any? #error_explanation %h2 = pluralize(@user.errors.count, "error") prohibited this username from being saved: %ul - @user.errors.full_messages.each do |msg| %li= msg .field = f.label :name = f.text_field :name .field = f.label :email =f.text_field :email .field = f.label :password = f.password_field :password = f.label :password_confirmation = f.password_field :password_confirmation .actions = f.submit 
+7
ruby ruby-on-rails password-confirmation
source share
1 answer

Since you are using rails 4, take a look at your strong parameter settings and make sure password_confirmation is enabled.

This is a new feature in rails 4: http://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html

+10
source share

All Articles