2

This is the direction I'm trying to go, but I can't get it to work with namespaced models.

class Surveys::Hospital::JobMatch < ActiveRecord::Base
  has_many :job_match_answers,
           :class_name => "Surveys::Hospital::JobMatchAnswer",
           :foreign_key => "surveys_hospital_job_match_id"

  validates_presence_of :job_match_answers
end

I'd like the users to see "Job titles" instead of "Job match answers" in the error message. I tried changing this in config/locales/en.yml. I've tried several combinations.

1) Nested namespaces

en:
  activerecord:
    attributes:
      surveys:
        hospital:
          job_match:
            job_match_answers: "Job titles"

2) Inline namespaces

en:
  activerecord:
    attributes:
      surveys_hospital_job_match:
        job_match_answers: "Job titles"

3) No namespaces

en:
  activerecord:
    attributes:
      job_match:
        job_match_answers: "Job titles"

Nothing works. How do I do this with namespaced models?

Community
  • 1
  • 1
Samo
  • 8,202
  • 13
  • 58
  • 95

1 Answers1

3

I hit the same issue, found your question first, and broadening my search to just en.yml found the answer in another question: Changing attributes name in en.yml file is not working

Slash "/" is the namespacing separator.

So

    en:
      activerecord:
         attributes:
           surveys/hospital/job_match:
             job_match_answers: "Job titles"
Community
  • 1
  • 1
Ed Allen
  • 86
  • 7