ruby on rails - Pluralized many-to-many but still uninitialized constant -
as per below think setup fine:
class location < activerecord::base has_many :traders has_many :servicelocations has_many :services, through: :servicelocations end class service < activerecord::base has_many :servicelocations has_many :locations, through: :servicelocations end class servicelocation < activerecord::base belongs_to :location belongs_to :service end class trader < activerecord::base belongs_to :location end
the problem still getting uninitialized constant error
.
i have noticed created model servicelocation, funky rails magic created service_location.rb unsure if a) problem , b) how fix if is.
i believe error came this
class service < activerecord::base has_many :servicelocations has_many :locations, through: :servicelocations end
these should this
class service < activerecord::base has_many :service_locations has_many :locations, through: :service_locations # notice underscore end
your model class name servicelocation
, rails convention name service_location
not servicelocation
and here also,you have change
class location < activerecord::base has_many :traders has_many :service_locations has_many :services, through: :service_locations end
Comments
Post a Comment