LearnWhat is a has_many :through association in Ruby on Rails? | Quick Tip

Avatar

Jason Seifer
writes on May 9, 2013

In this Treehouse Quick Tip, Jason demystifies the concepts behind what a has many :through association is in Ruby on Rails. We’ll figure out what a join table is, how different models fit together, and the syntax needed to make it all work. Score one for Treehouse!

GET STARTED NOW

Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you've been dreaming about.

Get Started

5 Responses to “What is a has_many :through association in Ruby on Rails? | Quick Tip”

  1. DFGHJKL;’;LKJHGFDSRTY89POIUYFFVBNM,.KJHG

  2. This was a great tip but it would be nice to see how to use it with nested attributes in a form and also how to set the strong parameters for it in rails 4.

  3. So, do you have any advice for OO actions that work on data stored on the join table? For instance, if you added a field to Subscriptions called “expired” for folks that quit paying their subscription fee, how would you access and/or update the “expired” field?

    Obviously, you can pull the subscription through a call like *sub = Subscription.where(user: user, magazine: magazine)*, but i didn’t know if working directly on the Subscription model is considered the Rails Way of working CRUD on join tables.

  4. Thanks for your great stuff!!

  5. water test kit on May 10, 2013 at 12:32 am said:

    Thanks for sharing some quick tips.

Leave a Reply

You must be logged in to post a comment.

man working on his laptop

Are you ready to start learning?

Learning with Treehouse for only 30 minutes a day can teach you the skills needed to land the job that you've been dreaming about.

Start a Free Trial
woman working on her laptop