0
carrierwave是给我这个验证错误:自定义carrierwave验证消息
Image You are not allowed to upload "pages" files, allowed types: jpg, jpeg, gif, png
任何想法如何从一开始就删除了“图像”属性位?它读得不好。
carrierwave是给我这个验证错误:自定义carrierwave验证消息
Image You are not allowed to upload "pages" files, allowed types: jpg, jpeg, gif, png
任何想法如何从一开始就删除了“图像”属性位?它读得不好。
我认为这应该工作:
class MyModel < ActiveRecord::Base
...
HUMANIZED_COLUMNS = {:image => ""}
def self.human_attribute_name(attribute)
HUMANIZED_COLUMNS[attribute.to_sym] || super
end
...
end
Documentation on human_attribute_name
或者,在你的区域设置文件中添加:
en:
activerecord:
attributes:
my_model:
image: ""
在这两种情况下,由名替换MyModel
/my_model
您正在将图像上传到的activerecord类。
谢谢,第一个给了我一个错误,第二个工作! – pingu
我想你试过https://github.com/jnicklas/carrierwave#i18n? – pjam
这不是一个载波问题,它是一个轨道问题,还有一个很老的问题:http://www.ruby-forum.com/topic/196109和http://stackoverflow.com/questions/808547/fully-custom -validation-error-message-with-rails –
@shioyama - 听起来像解决方案,但如何做carrierwave它? – pingu