[英]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.