I suggest you ...

Lets build a "has_many :through" Association

I would like to see a topic where we create a hasmany :through association in Rails 4. For example, if a doctor has many patients through appointments and appointments have dates, how do we do things like: doctor.appointments.today or appointments.today.patients.where(doctor_id: 1) ?

I have not been able to find a good example for hasmany :through.

I found a good example of a HABTM/Rails 4 http://habtmexample.herokuapp.com/instructions

10 votes
Vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
You have left! (?) (thinking…)
Matt shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

1 comment

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...
  • Adminar3 (Admin, Indianapolis Ruby Brigade) commented  ·   ·  Flag as inappropriate

    We are actually fighting with has_many :through right now on our project. We use it a ton, but something happened to break the assigning functionality from 4.0.5 to 4.0.8...I'd love to discuss this, because it is a powerful and important feature of ActiveRecord (and I personally hate HABTM :) )

Feedback and Knowledge Base