[Rails] Having trouble adding rows to an association

alex nanex kid nanex69120 at gmail.com
Mon May 1 09:21:49 GMT 2006


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

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list