Answer the question
In order to leave comments, you need to log in
How to properly organize data sampling and serialization ( RoR )?
Good day.
There is a users table:
id,name,created_at,updated_at
It is required by means of AR to make a certain selection and give it to json.
There are no problems with turning it into json - @users = User.all.as_json , the problem arises in the specifics of the selection. Requires users to be grouped by creation date ( created_at ).
In other words, the sample should look something like this:
"created_at" => [
"2015-01-01" => {
"users" => [ { "id" => 1, "name" => "Ivan"},
{ "id" => 2, "name" => "Sergey"] }
"2015-01-12" => {
"users" => [ { "id" => 3, "name" => "Ivan"},
{ "id" => 4 "name" => "Sergey"] }
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question