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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:57:28+00:00 2026-05-26T15:57:28+00:00

How does Rails 3.1 (RC4) and scoped mass assignment expect us to work with

  • 0

How does Rails 3.1 (RC4) and scoped mass assignment expect us to work with seeds.rb when loading a list of data.

For example. I normally have something like:

City.create([
  { :name => 'Chicago' }, 
  { :name => 'Copenhagen' }, 
  ...
]) 

Which creates over 100+ cities. this doesn’t work anymore since the City model has a scoped mass assignment :as => :admin.

As far as I know, the .create() method does not allow us to throw in :as => :admin.
Only .new() and .update_attributes() allows us to do this with :as => :admin.

So doing something like (below) is cumbersome (especially for 100+ records):

city1 = City.new({ :name => 'Chicago' }, :as => :admin)
city1.save
city2 = City.new({ :name => 'Copenhagen' }, :as => :admin)
city2.save

Any thoughts on this?

  • 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-05-26T15:57:29+00:00Added an answer on May 26, 2026 at 3:57 pm

    You can do the following:

    City.create([
      { :name => 'Chicago' }, 
      { :name => 'Copenhagen' }, 
      ...
    ], :without_protection => true) 
    

    This completely overrides the mass assignment protection – so be sure to only use this in say the seeds.

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

Sidebar

Related Questions

Does anyone have an example of setting up Authlogic with a namespace in Rails?
Where does Rails store data created by saving activerecord objects during tests? I thought
Does Rails 3 have an equivalent to MVC3 Areas? I think I came across
Does Rails 3 have anything akin to slices in Merb, or areas in Django
Does rails have a way to get JUST the src of an image as
I have a model that requires loading external data from an auxiliary source. A
Does Rails have an equivalent of the Server.MapPath method from ASP.NET? I've tried looking
Does rails have a break statement? I'm writing a controller that has some pretty
Does rails have any in-memory caching option, other than me having to install memcache/redis?
Does Rails 3 or Ruby have a built-in way to check if a variable

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.