Posted about 3 years ago. Visible to the public. Repeats. Linked content.

How to reload a belongs_to association

To reload a single-item association in Rails 5+, call #reload_<association>:

Copy
post.reload_author

In older Railses you can say

Copy
post.author(true)

By refactoring problematic code and creating automated tests, makandra can vastly improve the maintainability of your Rails application.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
about 1 month ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more