We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I expect each response should contains code & msg in addition to normal data. Looks like this:
{ code: 1000, msg: "OK", data: { // normal data goes here if exists } }
I have this code:
resources :books do get do present :code, 1000 present :msg, "OK" present :data do present :items, Book.all, with: Entities::Book end end end
Of course this won't work & not DRY. Is there an approach instead?
The text was updated successfully, but these errors were encountered:
I define a method:
def format_result(result, return_code=0) { API::RESPONSE_CODE => return_code, API::RESPONSE_RESULT => result.as_json } end
and then to use it like this:
format_result(::Entities::User.represent(agents))
grape-entity has a root method, but it looks doesn't work in subclass。
root
Anybody else have better solution?
Sorry, something went wrong.
This is exactly what I want, thanks so much!
This works. I encourage you to use a proper presenter framework like grape-entity or Roar and to stick to a JSON format like HAL.
No branches or pull requests
I expect each response should contains code & msg in addition to normal data. Looks like this:
I have this code:
Of course this won't work & not DRY. Is there an approach instead?
The text was updated successfully, but these errors were encountered: