Ruby on Rails Thursday, February 27, 2014

Hi,

I am trying to do the following database query (ie find all question
id's with the selected minisection id):

minisection_questions = Question.where(minisection_id:
minisection_id).pluck(:id)

I have a question table, a minisection table, and a
minisections_questions join table.

Question model - has_and_belongs_to_many :minisections
Minisection model - has_and_belongs_to_many :questions

I get the following error:
PGError: ERROR: column questions.minisection_id does not exist
LINE 1: SELECT id FROM "questions" WHERE "questions"."minisection_i...
^
: SELECT id FROM "questions" WHERE "questions"."minisection_id" = 2

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3202d2b108b746f5280797b3d3c43a2e%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment