0

I'm having trouble using it with STI and wondered if you can give me some pointers. I want to add attachments to discussion as well. I tried several attempts to make it work but always got exceptions.

do i need to add accepts_nested_attributes_for in discussion.rb ? do i need to add a column in the attachments table ?

class Post < ActiveRecord::Base
  has_many :attachments, :dependent => :destroy
  accepts_nested_attributes_for :attachments, :reject_if => lambda { |a| a[:url].blank? }, :allow_destroy => true
end

class Discussion  < Post
end

class Attachment < ActiveRecord::Base
belongs_to :post
end
Gady
  • 1,514
  • 2
  • 16
  • 32

1 Answers1

0

do i need to add accepts_nested_attributes_for in discussion.rb ?

If there is now any differences with parent class - No

do i need to add a column in the attachments table ?

Only post_id or any other key

fl00r
  • 82,987
  • 33
  • 217
  • 237