Validates_format_of?

时间:2011-01-24 17:28:17

标签: ruby-on-rails

1 error prohibited this {{model}} from being saved

  There were problems with the following fields:

    * {{attribute}} {{message}}

我收到此错误,我正在使用的代码是:

validates_format_of :user_id , :with => /\A(([0-9]{4})-[A-Z]{2}$)\Z/ , :message => "should be in the format 1111-TT", :allow_nil => true, :allow_blank => true

知道造成这种情况的原因是什么?

1 个答案:

答案 0 :(得分:1)

我使用Rails 2和i18n 0.5.0时遇到了同样的问题。卸载i18n 0.5.0或在您的环境中指定旧​​版本(我使用的是0.4.1)。