我有一种关系,用户可以有很多设计。
用户模型:
class User < ActiveRecord::Base le
has_many :designs
accepts_nested_attributes_for :designs
设计模型:
class Design < ActiveRecord::Base
has_attached_file :design,
:styles => { :medium => "300x300>", :thumb => "100x100>" },
:default_url => "/images/:style/missing.png" ,
:storage => :dropbox,
:dropbox_credentials => Rails.root.join("config/dropbox.yml"),
:dropbox_options => {environment: ENV["RACK_ENV"]}
belongs_to :user
end
设计控制器。
def create
if current_user.designs.create(design_params)
flash[:alert] = "Successfully created the design."
redirect_to designer_show_path
else
render designer_create_path
end
end
def new
@design = current_user.designs.build
end
现在一切正常,除非我上传图片后,它似乎永远继续下去甚至不到10k的svg文件。但对于其他图像格式,它工作得很好。