Hi, I have two database - tables (users and user_permissions) which have a 1..n - relationship. If I want to create a new entry on ''users'' table I need the correct user_permission_id from the other table. So the form which I use has a select list with all entries of the user_permissions - table but if anybody insert an invalid key into the select list I get inconsistent data in my database. How can I solve this problem? At this time I use "validates_inclusion_of" and "validates_associated" to solve this problem but without any success. Eddy -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Eddy, Eddy Betara wrote:> I have two database - tables (users and user_permissions) > which have a 1..n - relationship. If I want to create a new > entry on ''users'' table I need the correct user_permission_id > from the other table. So the form which I use has a select > list with all entries of the user_permissions - table but if > anybody insert an invalid key into the select list I get > inconsistent data in my database. How can I solve this > problem?The ''standard'' approach to this is to put an ''observe_field'' on the first select field which fires a method that, based on the value selected, re-renders (typically with RJS) the second select. If you''re new to RJS, Cody Fauser''s piece at O''Reilly is we''ll worth the $10. HTH, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Bill, thanks for your post but I looking for a solution for my ''user'' model which allows me to validate the user_permission_id with all entry of the user_permissions - table. Has anybody a solution or a tip for my problem? Eddy -- 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 -~----------~----~----~----~------~----~------~--~---
On 12 Jun 2008, at 12:48, Eddy Betara wrote:> > Hi, > > I have two database - tables (users and user_permissions) which have a > 1..n - relationship. If I want to create a new entry on ''users'' > table I > need the correct user_permission_id from the other table. So the form > which I use has a select list with all entries of the > user_permissions - > table but if anybody insert an invalid key into the select list I get > inconsistent data in my database. How can I solve this problem? >I would just use a foreign key. Fred> At this time I use "validates_inclusion_of" and "validates_associated" > to solve this problem but without any success. > > Eddy > -- > 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 -~----------~----~----~----~------~----~------~--~---