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 8561909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:36:39+00:00 2026-06-11T16:36:39+00:00

In my development and test environments, I want to seed the database with a

  • 0

In my development and test environments, I want to seed the database with a bunch of users. I’m using Ruby on Rails v3.2.8 and the latest Devise. So I added this line in my db/seeds.rb file:

User.create(email: 'test@example.com', encrypted_password: '#$taawktljasktlw4aaglj')

However, when I run rake db:setup, I get the following error:

rake aborted! Can’t mass-assign protected attributes:
encrypted_password

What is the proper way to seed users?

  • 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-11T16:36:41+00:00Added an answer on June 11, 2026 at 4:36 pm

    You have to do like this:

    user = User.new
    user.email = 'test@example.com'
    user.encrypted_password = '#$taawktljasktlw4aaglj'
    user.save!
    

    Read this guide to understand what mass-assignment is: http://guides.rubyonrails.org/security.html

    I am wondering why do have to directly set the encrypted password. You could do this:

    user.password = 'valid_password'
    user.password_confirmation = 'valid_password'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using rails 2.3.9 and I want database dump in sql manner. Here
I have this configuration in ibatis-config.xml <configuration> <properties resource=collector.properties/> <environments default=development> <environment id=development> <transactionManager
I want to test my IAP in a development ( sandbox ) environment. But
I have a Rails app using sqlite3. Anytime I want to save anything in
OK, I'm building my first rails 3.0 app and want to test the postgreSQL
I run my development environment in a VM and need to test the delivery
Are user stories (typically used in agile development or test driven development) the same
I'm just starting to get into test development and I'm struggling to understand what
Is Test Driven Development limited to OO? Or is it possible/useful to use it
Both are BDD (Behavior Driven Development) capable unit test frameworks for Scala written in

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.