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 옵션을 제거하면 작동한다는 것을 알았습니다. 무엇이 잘못 되었나요?
감사합니다. 레일 3.0.3, 당신은 (첨부 파일, 사진)를 파괴하려는 연결하기 때문에로드 할 필요 같은 샘
예. 티켓은 나에 의해 발급되었다 :-) 어쨌든 고마워. –
죄송합니다. 그럼 곧 진짜 수정에 대한 희망을 갖게됩니다. – mud
연결로드로 인해 문제가 해결되지 않았습니다. – Eytan