I am using Rails 5.2 for my application.
Request:
http://localhost:3000/reports
Response:
[
{
id: 1,
name: "Ram",
details: {
path: "dev/daily_summary_20190503.csv",
success_detail: "Report uploaded to S3"
},
status: "success"
},
{
id: 2,
name: "John",
details: {
path: "dev/daily_summary_20190504.csv",
error_detail: "Error in uploading report. Refer log for details"
},
status: "failed"
}
]
I want to add download_url, message parameters to every records where parameters is not added to schema. Following is my expected output,
Expected output:
[
{
id: 1,
name: "Ram",
details: {
path: "dev/daily_summary_20190503.csv",
success_detail: "Report uploaded to S3"
},
status: "success",
download_url: "https://<S3_HOST>/dev/daily_summary_20190503.csv",
message: "Report uploaded to S3"
},
{
id: 2,
name: "John",
details: {
error_detail: "Error in uploading report. Refer log for details"
},
status: "failed",
message: "Error in uploading report. Refer log for details"
}
]
I have tried using attr_accessor, but which doesn't help me to display download_url in all records of index method in controller.
How can I add the paramters for index and show of every records?