Ask A Question

Notifications

You’re not receiving notifications from this thread.

Data are different between the one from association and the one from the actual table

Calla Jiyoung Lee asked in Rails

I created 2 tables, Baby and BabyMonth. The BabyMonth has association with Month as well.
There are associations between them that Baby has_many BabyMonths.
After I soft_delete all baby_months by doing baby.baby_months.each(&:soft_delete), it properly updated database.
However, when I update the object by calling baby.baby_months.find_by(month: month).update, it updates the database, but does not update the result of baby.baby_months.
Is this expected behavior?

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,823+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.