繁体   English   中英

使用Paperclip和Rails 4无法保存图像

[英]Image will not save with Paperclip and Rails 4

我正在尝试使用Paperclip上传一个有很多的图像,并且属于与'pictures'的关系

我确定imagemagick等正确安装,因为我在这个项目中有更多的图像上传工作,不同的是这个有很多关系。

我没有在控制台中获得“保存附件”。 所以我的想法是强参数完全忽略了这一点。

在topicscontroller中:

params.require(:topic).permit(:id, :title, :content, :active, pictures_attributes: [:image, :id, :_destroy] )

在主题模型中:

has_many :pictures, dependent: :destroy
accepts_nested_attributes_for :pictures, allow_destroy: true
validates :title, :content, presence: true

在图片模型中:

belongs_to :topic

has_attached_file :image,
:styles => { :medium => "400x400#", :thumb => "200x200#", :small => "50x50#" },
:default_url => ActionController::Base.helpers.asset_path('missing.png')

我知道关于这个还有很多其他主题,只有所有都是rails 3,并且设置'attr_accessible'的方式不同

使用Paperclip 3.5.0版本,Rails 4的一切都很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM