Image will not save with Paperclip and Rails 4
我正在尝试使用回形针上载一张图片,该图片有很多并且属于与"图片"的关系。
我确定imagemagick等已正确安装,因为在该项目中我有更多的图像上载器可以正常工作,不同之处在于该对象有很多关系。
我没有在控制台中找到"保存附件"。所以我的想法是强参数完全忽略了这一点。
在topiccontroller中:
1 | params.require(:topic).permit(:id, :title, :content, :active, pictures_attributes: [:image, :id, :_destroy] ) |
在主题模型中:
1 2 3 | has_many :pictures, dependent: :destroy accepts_nested_attributes_for :pictures, allow_destroy: true validates :title, :content, presence: true |
在图片模型中:
1 2 3 4 5 | 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'的方式上有所不同
在3.5.0版的Paperclip中,Rails 4一切都很好。