ruby on rails - Can't get has_and_belongs_to_many association to create -


this first time creating has_and_belongs_to_many association , being less cooperative.

my models are

class server < activerecord::base   has_and_belongs_to_many :services 

and

class service < activerecord::base   has_and_belongs_to_many :services 

i'm trying create service through server object.

i've gotten server object server = server.find_by_name(server_name) works fine. if try create services object, either service = server.services.new or server.services.create(params) following activerecord error:

activerecord::hasandbelongstomanyassociationforeignkeyneeded: cannot create self referential has_and_belongs_to_many association on 'service#services'. :association_foreign_key cannot same :foreign_key. 

i haven't found in way of information error though. doing wrong?

simple error:

should has_and_belongs_to_many :servers in service class.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -