[Rails] Re: Active Record has_one through

2015-11-05 Thread Chris Berry
Turns out the event table needed to have an artist_id column. I was attempting to use the join table without a reference to the artist table. I dont know if that was the fix, because i also wrote a function in the event model that used the artist_id to return artist data from the database. I

[Rails] Re: Active Record has_one through

2015-10-30 Thread Travis Eubanks
why dont you just do this class Artist < ActiveRecord::Base has_many :events, dependent: :destroy end class Event < ActiveRecord::Base belongs_to :artist end a = Artist.first a.events which will return a list of events connected to that artist e = Event.first e.artist which will return

[Rails] Re: Active Record has_one through

2015-10-08 Thread Matt Jones
On Wednesday, 7 October 2015 20:47:54 UTC-4, Ruby-Forum.com User wrote: > > I have two tables in my app which I am attempting to relate through a > join table. The Artist class which uses 'has_many through', works as > expected. However, the Event class using 'has_one through', brings back >