A QuestionTag belongs_to a Tag.
I want to get the JSON representation of a QuestionTag, and some information from the Tag it belongs to. What is the correct Rails-Activerecord query to get me this structure from a controller action?
{
question_id: 1,
name: "PHP",
description: "A programming language for monkeys."
}
Here are the tables:
QuestionTag
question_id
tag_id
Tag
name
description
In you controller, when you send back the response in JSON format, you can do something like following:
Now, it will send response in the following format. It will send only
question_id
formQuestionTag
table.