blueprinter
blueprinter copied to clipboard
Hide identifier
is there a way to not send the identifier?
at the moment I'm returning
{
"data": {
"id": 7,
"token": "xxxxxxxxxxxxxxxxx"
},
"meta": {}
}
I want to send just
{
"data": {
"token": "xxxxxxxxxxxxxxxxx"
},
"meta": {}
}
my blueprint looks like this
class UserBlueprinter < Blueprinter::Base
fields :token
view :admin_view do
identifier :id
end
end
Hi @CarlosUvaSilva, I just responded to issue: https://github.com/procore/blueprinter/issues/271
identifieris a purely a developer convenience for being able to create a Blueprinter field that:
- Get's added to the
defaultview, and therefore will be included in all renders by default- By default Blueprinter sorts rendered keys by name, however, the
identifierfield is always sorted as first in the list.
Currently, if you do not want either of the developer convenience behaviors above, the best approach is to simply not use the identifier field, and instead create it as a regular field.