我有谷歌/堆栈溢出了几个小时,没有找到解决这个问题的办法.我想知道我的安装PaperClip是不成功的.我正在验证我的模型文件夹中的图像附件:
validates :image,presence: true,content_type: { content_type: ['image/jpeg','image/jpg','image/png','image/gif']},size: { less_than: 5.megabytes }
我也尝试过与github上的read me文件相似的代码:
validates_attachment :image,:presence => true,:content_type => { :content_type => 'image/jpeg','image/gif' },:size => { less_than: => 5.megabytes }
我试图使用单独的验证
validates_attachment_presence :image validates_attachment_content_type :image,:content_type => ['image/jpeg','image/gif'] validates_attachment_size :image,:less_than => 5.megabytes
我在所有情况下都会收到错误.或者:
Routing Error undefined method `before_image_post_process' for #<Class:0x00000101461750> Try running rake routes for more information on available routes.
要么:
NoMethodError in PinsController#index undefined method `key?' for nil:NilClass
解决方法
你的文件中有has_attached_file:image吗? 如果是,请确保它在validates_attachment之前.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。