Answer the question
In order to leave comments, you need to log in
How to return data from different entities in one request?
Hello! I want to build an application, for example, twitter. It should work like this:
1. The base template is loaded.
2. We send an Ajax request (for example, to get /user/{username})
3. We get a json response with all tweets, tags, information about the user, etc. 4. And on the front end, this whole thing will be sorted out
by
AngularJs
volume: how to give away all the data so gracefully at once? I am new to rails. In php I did something like this:
//Метод Контроллера для роута get /user/{current_user}
public function($current_user) {
$tags = new Tags();
$user = new User();
$profile = [
"tags" => $tags->get_tag($current_user)
"profile_info" => $user->get_info($current_user)
....
]
return json_encode($profile)
}
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