Bart Zonneveld wrote:
I having a lot of difficulty wrapping my head around the following. I'm
building a site for musicians, who can post Events where they perform.
So, Profile has_many :events, and Event habtm :profiles.
However, I want artists to be able to add additional people to their
show, such as people who aren't registered on my site. An example. DJ
Random is playing at this sweet club, together with his mate DJ John
Doe. They're both registered to my site, so looking up their profiles is
easy. However, DJ Tiesto (or insert any other dj here) is playing there
as well, and DJ Random wants to add Tiesto to his listing too. But,
Tiesto isn't registered to my site.
I was thinking about storing the "additional artists" (Tiesto in this
example) as a field in the join table, but I can't get those fields in
my event.artists collection.
When I query event.artists, Rails runs this SQL command: SELECT * FROM
profiles INNER JOIN artists_events ON profiles.id =
artists_events.artist_id WHERE (artists_events.event_id = 1 ), which
obviously doesn't get me the artists who don't have a profile.
Any ideas on how to achieve this? Thanks a bunch!
has_many :through may help you though I'm not sure that's necessarily the best approach.