Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nested Models attribute localization for error messages in Rails 3.1

I have a deeply nested models form.

When a nested model attribute is in error the error messages is displaying:

List items identifier url may not be blank.

Which is:

Model_name + attribute + localization file error message

The correct message should be:

Item link url may not be blank.

ruby-1.9.2-p290 :014 > ListItem.human_attribute_name("identifier")
=> "Item Link" 

Localization is otherwise working fine except for nested model attribute names in error messages.

Looks like it was a bug in 2.3.4 that was fixed, but I can't figure it out.

like image 733
Garrett Davis Avatar asked Feb 04 '26 08:02

Garrett Davis


1 Answers

the following is working for me. I've a Course model and a OfflineCourse Model. OfflineCourse is nested in Course.

The following YAML works correctly form me. Hope this helps

  course:
    title: Titolo
    subtitle: Sottotitolo
    description: Descrizione
    abstract: Abstract
    audience: A chi è rivolto?
    topic: Argomenti
    typology: Tipologia
    stars: Stelle
  course/offline_courses:
    start_date: Data inizio
    end_date: Data fine
    location: Luogo
    schedule: Programma
    visible: Visibile
    city: Città
like image 190
stefano salvucci Avatar answered Feb 05 '26 22:02

stefano salvucci



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!