radhames brito | 7 Sep 18:02
Picon
Gravatar

Re: Re: Polymorphic advice for this design

no you need single table inheritance


is way better in your case , read a bit about STI, it lets you create one table and one model and then inherit from that model

list this

class BaseSugesstions < ActiveRecord :: base

attr_accessible first_name, last_name, email, city_name, business_name

end

then

class citySugesstions < BaseSugesstions

attr_accessible first_name, last_name, email, city_name

end


class BaseSugesstions < BaseSugesstions

attr_accessible first_name, last_name, email, business_name

end

one table should on the database should have all the field defined in BaseSugesstions




On Tue, Sep 7, 2010 at 11:25 AM, Christian Fazzini <christian.fazzini-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
Hi Ar,

End-users can either be registered or non-registered users. Any type
of user can suggest a business and a city.

When they suggest a city, they have to put in their first_name,
last_name, email and city name.

When they suggest a business. They have to put in their first_name,
last_name, email, business name and business address.

Initially, I had it working with two separate models: city_suggestion
and business_suggestion. However, since both tables have fields that
can be reused (i.e. first_name, last_name, email), I was thinking of
using a polymorphic association.

I am not sure if this is the right approach or whether I should have
just stuck with my original solution (i.e. two separate tables:
city_suggestion and business_suggestion)


On Sep 7, 11:02 pm, Ar Chron <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Hmm... seems my interpretation of what you are attempting to do doesn't
> match very well with your unstated goals...  You were asking whether the
> suggestion model should be polymorphic...
>
> Sooo, what exactly is a suggestion in the context of your application
> (what are your users doing)?
> --
> Posted viahttp://www.ruby-forum.com/.

--
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Gmane