Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Advanced Social Features in Ruby on Rails Uploading Files Attaching Files: Part 1

Why do statuses belong to documents?

Shouldn't documents belong_to :statuses ?

How can a user's status belong to a file?

1 Answer

Maciej Czuchnowski
Maciej Czuchnowski
36,441 Points

I know it sounds weird, this would make me raise an eyebrow a few months month ago, but after watching one of GoRails videos I know that the only thing belongs_to does is it gives you a setter and getter for this attribute, so you can check and apply things more easily (in this case it's status.document and status.document=). Check out from minute 12:55: https://gorails.com/episodes/soft-delete-with-paranoia

At least that's how I understand the reason behind belongs_to in this case.