Ruby on Rails Friday, October 1, 2010

I think that the whether to separate or not Artists and Users for two
different tables depends
on whether are the models petty similar or not. If the only difference
is couple of new fields in the Artist
model and few new methods then there is no need to separate the
mapping into two tables. If there are
a lot of non-common columns you may also try to use :polymorphic =>
true association.

On Sep 30, 11:51 pm, Christian Fazzini <christian.fazz...@gmail.com>
wrote:
> I've got user and artist. The app allows users to register. And some
> of these registered users can sign up as an artist as well.
>
> Should user be an STI? Perhaps i can have user as an STI, member
> (registered users) and artist models that inherit from user?
>
> My concern is, if we go ahead with the STI approach. Consider this
> scenario. A user registers. The record is saved and type=user. Later
> on the same user signs up as an artist. How would we change the type
> for this user? Should this be done in the Artist controller, create
> method? i.e. a look up will be performed, and if user found (user.type
> = 'Artist'; user.save!)
>
> Or should user and artist be separate tables on their own? i.e. user
> has_one :artist, artist belongs_to :user?
>
> Any other better approach?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment