2013-07-21 28 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的一切都很好。