this solution doesn't fit with my project i have to explain :
the table MANDATES contain the list of possible mandates like : (0,mayor,city) (1,deputy mayor,city) (2,minister,state) (3,king,state) this list use by me to make a form where the user of my program can select the mandate related by user the table ELECTED contain the relation between user and mandate like : (0,John Smith,mayor,Chicago) (1,Brad X,mayor,New York) (2,Adrien Y,king,Brasil) (3,Anton Z,minister,Great Britain) NB: i replace user_id,mandate_id,place_id by user.name, mandate.name,place.name the solution which i see to do that are : 1)i have explain in the first post 2) duplicate the field place_type in the table ELECTED (maybe it is the easier solution?) 3) group tables MANDATES and ELECTED like that : MANDATES - id - name - place_id - place_type - user_id in that way i create all possible mandates with no user related to make the form and when i have a relation between user/mandate i create a copy of the mandate with the user_id what do you think about this solution? thanks adrien On Jun 28, 5:12 pm, Marnen Laibow-Koser <rails-mailing-l...@andreas- s.net> wrote: > Adrien Nom wrote: > > I want to do that way because i must save the possible mandates in one > > table. > > That's not a good rationale. The place_id is part of the mandate just > as much as the olace_type is, so it belongs in the mandates table. > > > Then i use an other table to save the relation between mandates > > and users. > > How can i do that with an other way ? > > If I understand you correctly, this will be very easy with your current > schema, once you make the change I am proposing. > > Basically, place_id is a property of the mandate, so it belongs in the > mandates table. Since you have mandate_id in elected, you can get the > place_id with something like @elected.mandate.place_id. > > > thanks for your answer > > adrien > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...@marnen.org > -- > 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---