!! #<ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: missing FROM-clause entry for table "activities"
LINE 1: ...T "availabilities".* FROM "availabilities" WHERE ("activitie...
^
These are the associations:
class Activity < ActiveRecord::Base
has_and_belongs_to_many :facilities
end
class Availability < ActiveRecord::Base
# Associations
belongs_to :facility
end
class Facility < ActiveRecord::Base
# Associations
has_and_belongs_to_many :activities
has_many :availabilities
end
There's a table called activities_facilities for the has_and_belongs_to_many
I had this working query:
But my view was getting a lot of information from Facilities and this resulted in an N+1 issue.
So I decided I should be using
includes
instead to eager load my associationsBut this results in an error:
These are the associations:
There's a table called
activities_facilities
for thehas_and_belongs_to_many