dto*_*efp 12 ruby validation ruby-on-rails attachment paperclip
我google搜索/堆栈溢出了几个小时,没有找到解决这个问题的方法.我想知道我的PaperClip安装是否以某种方式不成功.我正在尝试验证模型文件夹中的图像附件:
validates :image, presence: true,
content_type: { content_type: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif']},
size: { less_than: 5.megabytes }
Run Code Online (Sandbox Code Playgroud)
我也尝试过类似于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 }
Run Code Online (Sandbox Code Playgroud)
我试图使用个人验证
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
Run Code Online (Sandbox Code Playgroud)
在所有情况下我都会收到错误.或者:
Routing Error
undefined method `before_image_post_process' for #<Class:0x00000101461750>
Try running rake routes for more information on available routes.
Run Code Online (Sandbox Code Playgroud)
要么:
NoMethodError in PinsController#index
undefined method `key?' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5474 次 |
| 最近记录: |