我已经用谷歌搜索/堆栈溢出了几个小时,但没有找到解决这个问题的方法。我想知道我的 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/jpg', 'image/png', 'image/gif' },
:size => { less_than: => 5.megabytes }
而且我尝试使用单独的验证
validates_attachment_presence :image
validates_attachment_content_type :image,:content_type => ['image/jpeg', 'image/jpg', 'image/png', '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