How Rails 3.1 (RC4) and bulk assignment with extended range expect us to work with seeds.rb when loading a list of data.
For instance. I usually have something like:
City.create([ { :name => 'Chicago' }, { :name => 'Copenhagen' }, ... ])
Which creates more than 100 cities. this does not work anymore, since the city model has a limited mass assignment :as => :admin .
As far as I know, the .create() method does not allow us to throw :as => :admin . Only .new() and .update_attributes() allow us to do this with :as => :admin .
So doing something like (below) is cumbersome (especially for 100+ entries):
city1 = City.new({ :name => 'Chicago' }, :as => :admin) city1.save city2 = City.new({ :name => 'Copenhagen' }, :as => :admin) city2.save
Any thoughts on this?
source share