I have a transactions table and tags table connected via a many to many
relationship. Right now when I run this
user = USER[1]
Transaction
.eager(:tags)
.where(:user_id => user.id)
.order(Sequel.desc(:transactions__id))
.limit(10)
.to_json(:include => :tags)
SELECT * FROM `transactions` WHERE (`user_id` = 1) ORDER BY
`transactions`.`id` DESC LIMIT 10
SELECT `tags`.*, `tags_transactions`.`transaction_id` AS 'x_foreign_key_x'
FROM `tags` INNER JOIN `tags_transactions` ON (`tags_transactions`.`tag_id`
= `tags`.`id`) WHERE (`tags_transactions`.`transaction_id` IN (4, 3, 2, 1))
{"id":4,"amount":"0.2523E2","description":"Polygon","type":"expense","date":"2015-03-26
00:00:00 UTC",
"created_at":"2016-03-30 06:57:30 UTC","updated_at":"2016-03-30 06:57:30
UTC","user_id":1,
"account_id":1,"tags":["#<Tag:0x007ffb20d036d0>"]}
I revieve a json array with the tags column containing an array of Tag
objects, I was wondering if there was a way to retrieve only the tag name
from the tag object.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.