You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Company and a Position Models,
Company has many :positions and they have both a {Model}Translation Model.
When I create a Company and position in a multiple nested form:
<% form_for @Company do | company_form |%>
<% company_form.field_for :positions do | position_form |%>
<position_form.text_field :name>
<% end %>
<% end %>
Position#name is a translated attribute , all works, but when a i try to update the company and his position names the position name don't update.
And I got a "WARNING: Can't mass-assign these protected attributes: id"
Have you a idea of why that doesn't work please ?
P.S :
Started POST "/fr/companies/22" for 127.0.0.1 at Fri Jun 18 22:47:08 +0200 2010
Processing by CompaniesController#update as HTML
Parameters: {"company"=>{"name"=>"vzcxvx", "our_activity"=>"", "positions_attributes"=>{"0"=>{"name"=>"cx cxz cx ui", "id"=>"21"}}, "logo_url"=>"", "join_us"=>""}, "commit"=>"Confirmer les changements sur entreprise", "authenticity_token"=>"y1qgwSwWGOyef04agUnZrDr7OkYv6gBsW/yqvbt7S8k=", "id"=>"22", "locale"=>"fr"}
fr _{"name"=>"vzcxvx", "our_activity"=>"", "logo_url"=>"", "positions_attributes"=>{"0"=>{"name"=>"cx cxz cx ui", "id"=>"21"}}, "join_us"=>""}_
Company Load (0.7ms) SELECT "companies".* FROM "companies" WHERE ("companies"."id" = 22) LIMIT 1
Position Load (0.3ms) SELECT "positions".* FROM "positions" WHERE ("positions".company_id = 22) AND ("positions"."id" IN (21))
CompanyTranslation Load (0.4ms) SELECT "company_translations".* FROM "company_translations" WHERE ("company_translations".company_id = 22) AND ("company_translations"."locale" = 'fr') ORDER BY created_at DESC LIMIT 1
WARNING: Can't mass-assign these protected attributes: id
CACHE (0.0ms) SELECT "companies".* FROM "companies" WHERE ("companies"."id" = 22) LIMIT 1
CompanyTranslation Load (0.2ms) SELECT "company_translations"."id" FROM "company_translations" WHERE ("company_translations"."locale" = 'fr') AND ("company_translations"."company_id" = 22) AND ("company_translations".id <> 23) LIMIT 1
Redirected to http://0.0.0.0:3000/fr/companies/22
Completed 302 Found in 624ms
The text was updated successfully, but these errors were encountered:
This works if we change a non translated attribute at the same time of the translated attributes. So I think this is due to update_attribute method which not update attribute if no non-translated attributes has changed
Hello,
That is my code:
I have a Company and a Position Models,
Company has many :positions and they have both a {Model}Translation Model.
When I create a Company and position in a multiple nested form:
<% form_for @Company do | company_form |%>
<% company_form.field_for :positions do | position_form |%>
<position_form.text_field :name>
<% end %>
<% end %>
Position#name is a translated attribute , all works, but when a i try to update the company and his position names the position name don't update.
And I got a "WARNING: Can't mass-assign these protected attributes: id"
Have you a idea of why that doesn't work please ?
P.S :
Started POST "/fr/companies/22" for 127.0.0.1 at Fri Jun 18 22:47:08 +0200 2010
Processing by CompaniesController#update as HTML
Parameters: {"company"=>{"name"=>"vzcxvx", "our_activity"=>"", "positions_attributes"=>{"0"=>{"name"=>"cx cxz cx ui", "id"=>"21"}}, "logo_url"=>"", "join_us"=>""}, "commit"=>"Confirmer les changements sur entreprise", "authenticity_token"=>"y1qgwSwWGOyef04agUnZrDr7OkYv6gBsW/yqvbt7S8k=", "id"=>"22", "locale"=>"fr"}
fr
_{"name"=>"vzcxvx", "our_activity"=>"", "logo_url"=>"", "positions_attributes"=>{"0"=>{"name"=>"cx cxz cx ui", "id"=>"21"}}, "join_us"=>""}_
Company Load (0.7ms) SELECT "companies".* FROM "companies" WHERE ("companies"."id" = 22) LIMIT 1
Position Load (0.3ms) SELECT "positions".* FROM "positions" WHERE ("positions".company_id = 22) AND ("positions"."id" IN (21))
CompanyTranslation Load (0.4ms) SELECT "company_translations".* FROM "company_translations" WHERE ("company_translations".company_id = 22) AND ("company_translations"."locale" = 'fr') ORDER BY created_at DESC LIMIT 1
WARNING: Can't mass-assign these protected attributes: id
CACHE (0.0ms) SELECT "companies".* FROM "companies" WHERE ("companies"."id" = 22) LIMIT 1
CompanyTranslation Load (0.2ms) SELECT "company_translations"."id" FROM "company_translations" WHERE ("company_translations"."locale" = 'fr') AND ("company_translations"."company_id" = 22) AND ("company_translations".id <> 23) LIMIT 1
Redirected to http://0.0.0.0:3000/fr/companies/22
Completed 302 Found in 624ms
The text was updated successfully, but these errors were encountered: