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
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
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
>
3 matches
Mail list logo