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

setting up a controller for a has_many through a join table association

My first official question!

I have a course_topic join table that has a course_id & topic_id

class CourseTopic < ActiveRecord::Base
  belongs_to :topic
  belongs_to :course
end

I have a Course model

class Course < ActiveRecord::Base
  has_many :course_topics
  has_many :topics, :through => :course_topics
end

I have a topic model

class Topic < ActiveRecord::Base
  has_many :course_topics
  has_many :courses, :through => :course_topics
end

among multiple questions i have, my main one is how exactly is the create action gonna be written out in the controller of courses & topics and how does it fill in the CourseTopic table from those actions?