在rails 3.2.16 app表单提交中,错误消息不会流向视图。基于以下模型定义
validate :not_overlap
def not_overlap
errors.add(:start, 'message') if overlaps?
end
我无法插入翻译代码助手
以下是语言环境文件:
activerecord:
models:
optionrate: "Options"
attributes:
optionrate:
start: "Start"
end: "End"
errors:
models:
optionrate:
attributes:
start:
not_overlap: "Dates overlap existing options."
end:
not_overlap: "Dates overlap existing options"
我也不确定
<% @optionrate.errors.full_messages.each do |msg| %><%= msg %>
命令及其i18n ......
......使得3只兔子在
之后运行我做错了什么?
答案 0 :(得分:1)
我认为errors.add的第二个参数需要是您尝试添加的错误消息的符号。所以:
errors.add(:start, :not_overlap)
你现在可能已经解决了这个问题!