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
Post a Comment