Forum: Ruby on Rails Having trouble adding rows to an association

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
81709be8275077190e3a993731c68cac?d=identicon&s=25 Alex Nanex kid (nanex)
on 2006-05-01 11:21
hi everybody, when trying to add rows to a join table i get the
following error :
sequence doesn't exist

here are the models used

class Photo < ActiveRecord::Base
  has_many :endroits_photos,
           :dependent => true

  has_many :endroits_connus,
           :through => :endroits_photos
end

class EndroitsPhoto < ActiveRecord::Base
  belongs_to :photo
  belongs_to :endroits_connu
end

class EndroitsConnu < ActiveRecord::Base

  has_many :endroits_photos,
           :dependent => true,
           :foreign_key => "endroit_connu_id"

  has_many :photos,
           :through => :endroits_photos,
           :foreign_key => "endroit_connu_id"
end

this is the code used :

key = params[:post][:photo_id]
    @photo =
EndroitsConnu.find(params[:endroit]).endroits_photos.create(:photo =>
Photo.find(key))

the main problem is that rails searchs a sequence for the joind table
and such a sequence doesn't exist !!

if the someone catch the problem , it would be great !!

thanks
This topic is locked and can not be replied to.