I have some serious problem with understanding what is wrong in my code after implemented "has_secure_password" . My issue to use "has_secure_password" and create new User.
I am using rails 4
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5'
gem 'mysql2', '>= 0.3.13', '< 0.5'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'
2.2.3 :034 > user=User.new(name: "user2", email: "user2@mail.com", password: "1qaz!QAZ", password_confirmation: "1qaz!QAZ")
=> #
2.2.3 :035 > user.save!
(0.4ms) BEGIN
User Exists (0.3ms) SELECT 1 AS one FROM users
WHERE users
.email
= 'user2@mail.com' LIMIT 1
(0.1ms) ROLLBACK
ActiveRecord::RecordInvalid: Validation failed: Password can't be blank
My User model
class User < ActiveRecord::Base
attr_accessor :password, :password_confirmation, :remember_token
has_secure_password
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
before_save { email.downcase! }
validates :password, length: { minimum: 6 }
end
please help me to understand what is wrong in my code.