The title is likely bad at explaining what I need.
Here's what that need is...
I have two models. Walkthru and WalkthruComplete.
Walkthru has columns (:id, :name, :reward) WalkthruComplete has columns (:id, :user_id, :walkthru_id)
If a user completes a walkthru/guide in my application, a new row will be written to WalkthruComplete, saying for instance that user_id 17 completed walkthru_id 2. They may be rewarded some points for this.
Now, I need to fetch all the available walkthrus. This is easy. However, I want to include more than Walkthru.(:id, :name, :reward). I also would like to include a column I make up on the fly called 'completed'. In my Walkthru#index, I will check to see if the particular user requesting the Walkthru#index has any WalkthruComplete rows. If they do, 'completed' would be set to YES for those particular walkthrus. If they don't, 'completed' would be set to NO.
The reason the user_id is not set to Walkthru is because some walkthrus are allows for any users, including non-signed in users. Others are only for signed in users, and reward points to those signed in users.
In the end I want something like...
{
"walkthrus": [
{
"id": 1,
"name": "Intro",
"reward": 0,
"completed": 0
},
{
"id": 2,
"name": "Widgets",
"reward": 10,
"completed": 1
},
{
"id": 3,
"name": "Gadgets",
"reward": 10,
"completed": 0
}
]
}