2
我正在開發一個rails 3應用程序。回形針的問題accept_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選項,它的作品。 有什麼問題?
謝謝。
山姆
是的。票是由我發出的。:-)無論如何。 – 2011-02-18 07:01:44