using the paperclip gem i want to validate the production part when someone uploads a image.It works in development but not in production mode
使用paperclip gem我想在有人上传图片时验证生产部件。它在开发中工作但不在生产模式下工作
class Listing < ActiveRecord::Base
if Rails.env.development?
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png)
else
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png)
:storage => :dropbox,
:dropbox_credentials => Rails.root.join("config/dropbox.yml")
:path => ":style/:id_:filename"
end
end
getting error
得到错误
/etsydemo2014/app/models/listing.rb:12: syntax error, unexpected =>, expecting keyword_end :storage => :dropbox, ^ /Users/neilpatel/Desktop/Rails/etsydemo2014/app/models/listing.rb:13: syntax error, unexpected ',', expecting keyword_end
/etsydemo2014/app/models/listing.rb:12:语法错误,意外=>,期待keyword_end:storage =>:dropbox,^ /Users/neilpatel/Desktop/Rails/etsydemo2014/app/models/listing.rb:13 :语法错误,意外',',期待keyword_end
1 个解决方案
#1
3
You are missing comma at end of validation. Thus, practically you were not adding any of those remaining constraints. Change that to :
您在验证结束时缺少逗号。因此,实际上你没有添加任何剩余的约束。改为:
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png), :storage => :dropbox,
:dropbox_credentials => Rails.root.join("config/dropbox.yml"),
:path => ":style/:id_:filename"
Notice the comma at end of content_type
key which is preceded by storage
.
注意以content_type键结尾的逗号,前面是存储。
#1
3
You are missing comma at end of validation. Thus, practically you were not adding any of those remaining constraints. Change that to :
您在验证结束时缺少逗号。因此,实际上你没有添加任何剩余的约束。改为:
has_attached_file :image, :styles => { :medium => "200x", :thumb => "100x100>" }, :default_url => "default.jpg"
validates_attachment_content_type :image, :content_type => %w(image/jpeg image/jpg image/png), :storage => :dropbox,
:dropbox_credentials => Rails.root.join("config/dropbox.yml"),
:path => ":style/:id_:filename"
Notice the comma at end of content_type
key which is preceded by storage
.
注意以content_type键结尾的逗号,前面是存储。