Home>
What you ’re trying to implement

I'm trying to return results in JSON using the Rails API.

Do not change

How to get relation destination data logically deleted in Paranoia
The parent can be obtained with with_deleted as described below, but the child data cannot be obtained at the same time.

What you can and cannot do

With_deleted was able to get the parent, but not the child data.
Specifically, I was able to get it with the following code.

@campaigns = Campaign.with_deleted.eager_load (: campaign_costs) .all
class Campaign
class CampaignCost

If i understand, I would appreciate it if you could teach me.

  • Answer # 1

    Currently, the default scope has been turned off as follows, but if there is any other good method, please continue your favors.

    class CampaignCost

Related articles