Rails validates 验证字段的错误信息设置中文后出错

wgf4242 · December 20, 2012 · Last by greatghoul replied at December 20, 2012 · 2355 hits

validates_length_of :title, :minimum => 10, :too_short => "输入的字符至少要 10 位." 比如这样写就这样出错 E:/Ruby/Project/depot/app/models/product.rb:9: syntax error, unexpected $end, expecting keyword_end ...inimum => 10, :too_short => "输入的字符至少要 10 位。"

下面这样写英文的就正常。 validates_length_of :title, :minimum => 10, :too_short => 'at least 10'

文件头上加 #-- coding: utf-8 --

You need to Sign in before reply, if you don't have an account, please Sign up first.