self_referential has_many :through problem (can't make it work)


I can't make self referential has_many :through associations work:

    base_production.suggestions << suggested_production

, where suggestions are stored in SQL:    table: suggestionships    column (production_id, suggestion_id) Rails:    class Suggestionship < ActiveRecord::Base      belongs_to :production      belongs_to :suggestion , :class_name => 'Production'    end

PROBLEM:     'suggestion_id' is NULL, whenever a new 'suggestionship' is created with     foo.suggestions << bar


   class Production < ActiveRecord::Base      has_many :suggestionships      has_many :suggestions , :through => :suggestionships , :source => :production    end

It must be obvious but I can't see it. Any idea? TIA


I believe this syntax...

foo.suggestions << bar

is only supported in Edge for has_many :through. So, for now, you'll need to do something like...

Suggestionship.create(:production_id =>, :suggestion_id =>

Alain Ravet wrote: