Right now I get:
{"id":1,"name":"HerzASS ratiopharm","dosage":null}
I would like to return ""
instead of null
But as default. How to achieve that. I don't want to add m.dosage || ""
for each attribute in my application.
I am keeping my jbuilder views in views/api/documents/_document.json.jbuilder
json.id document.id
json.category document.category # sometimes this is nil
json.note document.note
json.attachments document.attachments do |attachment|
json.url URI.join(request.url, attachment.url).to_s
end
json.created_at document.created_at
json.updated_at document.updated_at