Given these relationships:
User
has_many :queue_items
has_many :things, through: :queue_items
QueueItem
belongs_to :user
belongs_to :thing
Thing
has_many :queue_items
The mechanism I have to use is as follows:
@user = User.find(n)
respond_with @user.things
... because the api should return the items, which are the real data objects we care about.
BUT,
there's a couple of attributes in the queue I care about. created_at, and widget, which are important to display.
so, Q: How do i access the queue object given this setup?
Obviously i can't do thing.queue_item
--- because it doesn't exist.
And I know we've gotten the data, because we had to join on the queue table to get at it.
In pure sql, this will return all the data we care for:
SELECT queue_items.*, things.* FROM queue_items INNER JOIN things ON queue_items.thing_id = things.id WHERE queue_items.user_id = 1