2009/3/16 Simone R.
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
>
> Hi again... :-)
>
>
> I''m still working on RoR
>
>
> right now i''m fighting against relationship.
>
>
> I generated 3 scaffolds
> car
> wheel
> engine
>
>
> all the 3 CRUD works and now in the database I''ve many engines ,
many
> wheel and many cars.
>
> I want to correlate this object but how do it ?
>
>
> I must say that car has_one engine and engine belongs_to car
> (every car can have only one engine)
>
> or i must write that engine has_many cars and car belongs_to engine
> (one engine is used on many different car)
>
>
> or I need to create a new scaffold like road_ready_car which has_one
> engine , has_one car and has_many wheels
>
It all depends what you want in the database. Are the cars in the database
individual cars, or types of car? If types of car then maybe the name is
wrong. Similarly are the engines actual engines or just types of engines?
The same for wheels.
If they are all actual individual items then a car has only one engine and
an engine has only one car (at any one time at least). A car has 4 wheels (5
including spare?) so car has many wheels, wheel belongs to car.
If, however you are talking about types of cars and engines then a car type
may have many engine types and an engine type may have many car types.
Perhaps in this case you then need another table for the actual cars where a
car is of one car type, one engine type and one wheel type.
>
> ????
> --
> Posted via http://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---