fidel / batch_translations

Helpers to allow saving multiple Globalize3 translations in the same request
http://github.com/fidel
48 stars 8 forks source link

WARNING: Can't mass-assign protected attributes: #2

Open fad opened 13 years ago

fad commented 13 years ago

I love the idea of this plugin to integrate with the default form. Sadly I can't get it to work.

I did as told in the readme. Had to change <% f.globalize_fields_for :es do |g| %> to <%= f.globalize_fields_for :es do |g| %> though.

But when I submit, I get "WARNING: Can't mass-assign protected attributes: name" in my case and the translation is not set. I have "accepts_nested_attributes_for :translations" in my model file and tried around with attr_accessible, but to no avail.

Any ideas? (Rails is 3.0.3)

fidel commented 13 years ago

Hmm, I've developed this plugin long time ago, but I tested it and it works for me.

Try to add in your model attr_accessible :translations - I think that's the problem. Which version of globalize3 you use?

Regards!

fad commented 13 years ago

I added this to my gemfile for globalize: gem 'globalize3', :git => 'git://github.com/galetahub/globalize3.git' So I guess the current one. Rails: 3.0.4 Ruby: 1.8.7

Tried "attr_accessible :translations" before. Didn't work: Started POST "/admin/categories/1?locale=de" for 127.0.0.1 at Fri Jul 22 07:23:44 +0200 2011 Processing by CategoriesController#update as HTML Parameters: {"commit"=>"Update", "category"=>{"translations_attributes"=>{"1"=>{"name"=>"action", "id"=>"11", "locale"=>"es"}}, "name"=>"Action"}, "authenticity_token"=>"1QAI7xELVyFZ00gnls3K9rfiv2Hb1DHXWHg5iNGadII=", "utf8"=>"✓", "id"=>"1", "locale"=>"de"} Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE ("categories"."id" = 1) LIMIT 1 WARNING: Can't mass-assign protected attributes: translations_attributes, name

I will start a clean project later and try there and give you feedback.

Backoo commented 12 years ago

I am getting the same problem, so I opened a question at http://stackoverflow.com/questions/10139245/how-to-solve-the-cant-mass-assign-protected-attributes-translations-attribute.