2013-07-21 26 views
0

我试图用回形针上传的图像为有许多属于与关系“图片”图像不会与回形针和Rails节省4

我敢肯定,ImageMagick的等,已正确安装,因为我在这个项目中有更多的图像上传工具,不同之处在于这个图像具有很多关系。

我没有在控制台中找到'Saving Attachment'。所以我的想法是,这一点完全被强大的参数所忽略。

在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') 

我知道有这个许多其他议题,只有所有的导轨3并且在设置方式上有所不同'attr_accessible'

+0

您是否尝试过[rails-4](https://github.com/thoughtbot/paperclip/tree/rails-4)分支的回形针? –

+0

不,因为这必须工作,因为在其他项目上,这不是问题。但是这次我设法弄错了一些错误。 “未经许可的参数:title_text,image”,这是对的:因为我没有严格遵循许可参数,但没有发生错误。 “params.require(:topic).permit(:id,:title,:content,:active,pictures_attributes:{picture:[:image,:title_text]})”,我尝试了所有方法,但是正确的一个我猜.. – Loed

回答

2

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