-
Notifications
You must be signed in to change notification settings - Fork 442
Open
Description
File Structure:
config/initializers/jbuilder.rb
Jbuilder.ignore_nil
Jbuilder.key_format camelize: :lower
Jbuilder.deep_format_keys
config/routes.rb
namespace 'api', defaults: { format: :json } do
namespace 'v1' do
resource 'post', only: [:create]
end
end
app/views/layouts/application.json.jbuilder
json.success @result.success?
json.merge! yield
app/views/api/v1/posts/create.json.jbuilder
json.data @model
Expected Result:
{
success: true,
data: {
id: 1,
subject: 'Test',
content: 'Testing Content',
createdAt: 'some timestamp'
}
}
Actual Result:
{
data: {
id: 1,
subject: 'Test',
content: 'Testing Content',
created_at: 'some timestamp',
updated_at: nil
}
}
I don't think I've set up the initializer wrong as inside the create.json.jbuilder, I used a debugger and checked that calling json, I can see that ignore_nil and other specified options have been set correctly. Yet the actual behaviour is not according to the expectations.
P.S: It's also not loading the success attribute from application.json.jbuilder that I had mentioned.
Any help regarding this would be nice 😄
Metadata
Metadata
Assignees
Labels
No labels