Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,440 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.