2014-06-23 69 views
2

如何使用簡單形式輸出字段的完整錯誤消息?等效軌:<%= RESOURCE.errors.full_messages %>以簡單的形式顯示完整的錯誤消息?

例如顯示此:

"Email has already been taken", 
"Password confirmation doesn't match Password", 
"Password is too short (minimum is 8 characters)" 

代替:f.error_notification

"has already been taken", 
"doesn't match Password", 
"is too short (minimum is 8 characters)" 

simple_form(3.0.2)/ Rails的4.1.1

+0

很想知道這個問題的答案呢! –

+1

我被騙了。我無法讓它工作。所以我在初始化器中禁用了自動錯誤,並在每個字段下插入了f.full_error:token。雖然它的工作原理,我仍然有汽車版本.... – fyz

回答

5

如果有人還是想知道有一個簡單的方法來做到這現在,如標號here

簡單地根據config/initializers/simple_form.rb更改b.user :errorb.user :full_error,現在你的錯誤信息將是RESOURCE.errors.full_messages

注等價的:如果你使用的引導瓦特/簡單的形式更改simple_form_bootstrap.rb

+2

我認爲你應該增加一些重點改變'simple_form_bootstrap.rb'爲那些使用引導 –

+0

請注意,該行是'b.use:error',和而不是'b.user:error' – ndbroadbent