Ok, Ive got the following models:User, Artist and Video
User is 1:1 with Artist (A user can register to be an artist)
Artist is 1:M with Video (An artist can have one or many videos)
Note that, before any user can register as an artist. He/she must
already have an account with the system. i.e. He must be a registered
user first. Hence the 1:1 relationship with User and Artist.
Here is the problem, when an artist tries to upload a video:
@video = Video.new(params[:video])
@video.artist = current_user.artist
For this particular user:
In the User model, he has id => 29
In the Artist model, he has id => 1, user_id => 29 (user_id being the
This means, when the video record is saved to the db. It is saved as:
id => 1, artist_id => 1 (instead of 29), title => ‘foobar’, etc
How can such be fixed? Should I remodel my schema? I was thinking of
just having one User model and have this as an STI. Member (Registered
users) and Artist models would inherit from the User model.
What is a better approach to fixing this?