使用回形针创业板,当有人上传image.It时,我想验证生产部件在开发中工作,而不是在生产模式下工作。
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获取误差
/etsydemo2014 2014/app/model/listing.rb:12:语法错误,意外的=>,期待的keyword_end :存储=> :dropbox,^ keyword_end语法错误,意外',',期待keyword_end
发布于 2014-05-17 14:53:16
您在验证结束时缺少逗号。因此,实际上您没有添加任何剩下的约束。将其改为:
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"注意content_type键末尾的逗号,它前面是storage。
https://stackoverflow.com/questions/23712657
复制相似问题