-
Notifications
You must be signed in to change notification settings - Fork 616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WARNING: Can't mass-assign protected attributes: id #7
Comments
Thanks rockrep, I'll check this out. |
I'm getting this using AR model version as well. |
A little poking around in the source shows that if I hand you a an AR model you rip out its attributes and then instantiate a new AR model later on. Seems like it be would more efficient to simply re-use the models I've already given you? |
What version of ActiveRecord are you getting this warning with? Also, what other gems might you be using? I cannot reproduce the warning with ActiveRecord 3.0.5. |
I was using 3.0.3. I'll try again shortly once I upgrade to 3.0.5 |
I'm actually getting the same error myself with activerecord 3.0.5 and the latest activerecord-import gem using the following code (if it helps):
The import still seems to be working, but that warning is being issued in my logs. |
I think this line:
It having the ID column included by using default all columns from the DB table. What you can do is to put an array of columns as the first parameters to tell what column included, example: Item.import [:name, :author, :price] items However, the instructions did not mention this as the second parameters are models, not values. |
Is there an official workaround to this issue, as I am having it as well. Thanks for the great plugin! |
@everyone, This issue should no longer exist in activerecord-import 0.2.7 which was released tonight. @jpfuentes2, your suggestion of re-using models is a good one. Would you mind putting that in its own issue? Thanks everyone, |
Confirming the issue is fixed in version 0.2.7 -- thank you! |
Using the Array version of import, i.e.
posts = [ BlogPost.new :author_name=>'Zach Dennis', :title=>'AREXT',
BlogPost.new :author_name=>'Zach Dennis', :title=>'AREXT2',
BlogPost.new :author_name=>'Zach Dennis', :title=>'AREXT3' ]
BlogPost.import posts
The :id attribute should be removed from the attribute_array prior to insert.
The text was updated successfully, but these errors were encountered: