I'd like to turn a response from the following query:
sites = Site.find(request.review_sites).pluck(:id, :location_id, :site_name, :review_url,:created_at)
which provided output like below,
[
[
50,
2,
"google",
"https://search.google.com/local/writereview?placeid=000000001flMRNRVr8YpJWuY",
Thu, 06 Dec 2018 20:18:29 UTC +00:00
],
[
51,
2,
"facebook",
"https://www.facebook.com/biz/reviews/?ref=page_internal",
Thu, 06 Dec 2018 20:18:35 UTC +00:00
]
]
into a nested hash like the following (which I'll be working with as JSON quite a bit later):
{
:google => {
:id => 50,
:create_at => "2018-12-06T20:18:29.651Z",
:site_name => "google",
:review_url => "https://search.google.com/local/writereview?placeid=00000000001flMRNRVr8YpJWuY",
:location_id => 2
},
:facebook => {
:id => 51,
:create_at => "2018-12-06T20:18:35.639Z",
:site_name => "facebook",
:review_url => "https://www.facebook.com/biz/reviews/?ref=page_internal",
:location_id => 2
}
}
I realize this is a duplicate, but I'm struggling to implement some answers given. I'm struggling to do this programmatically, so any help would be appreciated.
Site, what ispluck? Ruby does not have such things.