2
私はレール3アプリケーションを開発中です。accepts_nested_attributes_forとreject_ifのペーパークリップの問題
class Post < ActiveRecord::Base
has_many :attachments
has_many :photos
accepts_nested_attributes_for :attachments, :allow_destroy => true, :reject_if => proc { |attrs| attrs['document'].blank? }
accepts_nested_attributes_for :photos, :allow_destroy => true, :reject_if => proc { |attrs| attrs['image'].blank? }
end
class Attachment < ActiveRecord::Base
belongs_to :post
has_attached_file :document
end
class Photo < ActiveRecord::Base
belongs_to :post
has_attached_file :image, :styles => {
:thumb => "100x100#",
:small => "150x150>",
:mid => "640x640>",
:large => "800x800>"
}
end
「_destroy」=>「1」は添付ファイルや写真では機能しません。 reject_ifオプションを削除しても動作することが分かりました。 どうしたの?
ありがとうございました。 Railsの3.0.3以来、あなたは(添付ファイル、写真)を破壊したい団体をロードする必要があるよう
サム
うん。チケットは私によって発行されました:-)どうもありがとう。 –
おっと私はそれを見ます。まあまもなく本物の修正を希望します。 – mud
アソシエーションをロードしても私の問題は解決しませんでした。 – Eytan