# ActiveRecord accepts\_nested\_attributes\_for problem

**URL:** <https://www.ruby-forum.com/t/activerecord-accepts-nested-attributes-for-problem/225395>\
**Category:** Rails I18n\
**Created:** [January 5, 2013, 9:25pm UTC](https://www.ruby-forum.com/t/activerecord-accepts-nested-attributes-for-problem/225395 "2013-01-05T21:25:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [January 5, 2013, 9:25pm UTC](https://www.ruby-forum.com/t/activerecord-accepts-nested-attributes-for-problem/225395/1 "2013-01-05T21:25:02Z")

</div>

I’m in this case:  
class Man \< ActiveRecord::Base  
has\_many :eyes  
accepts\_nested\_attributes\_for :eyes  
end  
class Eye \< ActiveRecord::Base  
belongs\_to :man  
validates\_inclusion\_of :color, in: { %w[brown green blue] }  
end

Views (in HAML):  
= form\_for @man do |f|

- if @man.errors.any?  
#error\_explanation  
%h2= t ‘errors.messages.record\_invalid’, count: @man.errors.count  
%ul  
- @man.errors.full\_messages.each do |msg|  
%li= msg

= f.fields\_for(:eyes) do |b|  
.field  
= b.label :color  
= b.text\_field :color

.actions  
= f.submit ‘Send’

it.yml:  
it:  
activerecord:  
attributes:  
customer/eyes:  
color: Colore  
errors:  
models:  
man/eyes:  
color:  
inclusion: non valido

However the label of color is not translated (but it is with  
‘actviterecord.attributes.eye.color’), the attribute in the error  
message is “Eyes” and the rest is not translated…  
I’m using Rails 3.2.6 and digging in the active\_model/translations.rb it  
seems to manage the model/sub\_model syntax.  
Someone can give me and hand? Thanks.

---

<div class="post-metadata">

**Author:** ![iazel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/13edae/32.png) [@iazel](https://www.ruby-forum.com/u/iazel)\
**Post date:** [January 15, 2013, 11:50am UTC](https://www.ruby-forum.com/t/activerecord-accepts-nested-attributes-for-problem/225395/2 "2013-01-15T11:50:00Z")

</div>

massa… parece ser simples de utilizar…

On 5 January 2013 18:25, Salvatore P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Views (in HAML):  
> = b.label :color  
> customer/eyes:  
> I’m using Rails 3.6 and digging in the active\_model/translations.rb it  
> To unsubscribe from this group, send email to  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid).  
> For more options, visit this group at  
> [http://groups.google.com/group/rails-i18n?hl=en](http://groups.google.com/group/rails-i18n?hl=en).

–  
Bruno da Silva Joo  
Telecommunication Technician  
Network Administrator  
Gmail & Gtalk: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
MSN: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Fone: +55 (48) 96585472 (TIM)
