Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7903961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:52:40+00:00 2026-06-03T09:52:40+00:00

I am learning ruby on rails. I am creating a model for storing User

  • 0

I am learning ruby on rails. I am creating a model for storing User information and when calling rake db:seed then I am getting the following error , any idea what I am missing ?

rake db:seed

require 'digest'
class User < ActiveRecord::Base
  attr_accessor :password 
  attr_accessible :email, :password
  validates :email, :uniqueness => true, 
                                    :length => {:within => 5..50},
                                    :presence => true

  validates :password, :confirmation => true, :length => { :within => 4..20 }, :presence => true, :if => :password_required?

  has_one :profile

  has_many :articles, :order => 'published_at DESC, title ASC',
                      :dependent => :nullify
  has_many :replies, :through => :articles, :source => :comments

  before_save :encrypt_new_password

  def self.authenticate(email, password)
    user = find_by_email(email)
        return user if user && user.authenticated?(password)
  end

  def authenticated?(password)
    self.hashed_password == encrypt(password)
  end


  def encrypt_new_password
    return if password.blank?
      self.hashed_password  = encrypt(password)                                                                                                                                                                                                                                                                                                                                                                                                                                                              
  end

  def password_required?
    hashed_password.blank? || password.present?
  end

 def encrypt(string)
   Digest::SHA2.hexdigest(string)
 end 

end




Can't mass-assign protected attributes: password_confrimation
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:20:in `debug_protected_attribute_removal'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:12:in `sanitize'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security.rb:230:in `sanitize_for_mass_assignment'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/attribute_assignment.rb:75:in `assign_attributes'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/base.rb:498:in `initialize'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/persistence.rb:44:in `new'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/persistence.rb:44:in `create'
C:/Users/huzaifa.gain/My Documents/Aptana Studio 3 Workspace/blog/db/seeds.rb:6:in `<top (required)>'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `block in load'
c:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:23
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:52:41+00:00Added an answer on June 3, 2026 at 9:52 am

    You have to add password_confirmation to attr_accessible

    class User < ActiveRecord::Base
      attr_accessor :password 
      attr_accessible :email, :password, :password_confirmation
    

    and it should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning ruby on rails by following the tutorials in http://ruby.railstutorial.org/ . I'm getting
Learning Ruby and Rails. In following the getting started guide if I invoke rails
I'm just learning ruby on rails and I have a table of user roles
I'm learning ruby on rails by following Patrick Lenz's book from Sitepoint. I know
I'm learning Ruby on Rails and doing the contactlist thing, 20 minute blog and
I'm learning Ruby on Rails. I'm using some associations (has_many :through, ...) But i'm
I am learning ruby on rails. I started by importing some data into a
I am learning Ruby on Rails and i did this scaffolding command: rails g
I'm a PHP developer learning Ruby on Rails by reading Michael Hartl's tutorial .
I'm just learning how to program in Ruby on Rails, and I'm really impressed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.