Предложения приветствуются.
я есть следующие модели:
class Evaluation < ActiveRecord::Base
attr_accessible :product_id, :description, :evaluation_institutions_attributes
has_many :evaluation_institutions, :dependent => :destroy
accepts_nested_attributes_for :evaluation_institutions, :reject_if => lambda { |a| a[:token].blank? }, :allow_destroy => true
validate :requires_at_least_one_institution
private
def requires_at_least_one_institution
if evaluation_institution_ids.nil? || evaluation_institution_ids.length == 0
errors.add_to_base("Please select at least one institution")
end
end
end
class EvaluationInstitution < ActiveRecord::Base
attr_accessible :evaluation_institution_departments_attributes, :institution_id
belongs_to :evaluation
has_many :evaluation_institution_departments, :dependent => :destroy
accepts_nested_attributes_for :evaluation_institution_departments, :reject_if => lambda { |a| a[:department_id].blank? }, :allow_destroy => true
validate :requires_at_least_one_department
private
def requires_at_least_one_department
if evaluation_institution_departments.nil? || evaluation_institution_departments.length == 0
errors.add_to_base("Please select at least one department")
end
end
end
class EvaluationInstitutionDepartment < ActiveRecord::Base
belongs_to :evaluation_institution
belongs_to :department
end
У меня есть форма для оценки, которая включает вложенные атрибуты для EvaluationInstitution и EvaluationInstitutionDepartment, поэтому моя форма вложена в 3 уровня. 3-й уровень доставляет мне проблемы.
Ошибки запускаются, как и ожидалось, но когда ошибка срабатывает для require_at_least_one_department, текст читается
База оценочных учреждений Пожалуйста, выберите хотя бы один отдел
Сообщение должно гласить «Пожалуйста, выберите хотя бы один отдел».
Как убрать «Базу оценочных институтов»?