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

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Alex N. (Guest)
on 2006-05-01 13: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

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

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"

this is the code used :

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

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 !!

This topic is locked and can not be replied to.