0

i have a join table between alarms and lists, and have a join table between lists and cars, i want to find the alarm to be notified when a certain car is added in a certain list, i tried to use alarm.list.cars but that's doesn't work any help please Thanks in advance

  • I think you're looking for a `has_many_through` relationship. You might want to look at these. http://blog.teamtreehouse.com/what-is-a-has_many-through-association-in-ruby-on-rails-treehouse-quick-tip http://stackoverflow.com/questions/11600928/when-should-one-use-a-has-many-through-relation-in-rails – Arun Kumar Mohan Aug 04 '16 at 18:24
  • in alarm model i made has_and_belongs_to_many :cars, through: :list and in car model i made that has_one :alarms, through: :list but when i try to call alarm.list.car it gives an error – peterateftawfik Aug 07 '16 at 10:08

0 Answers0