Hi list First a brief disclaimer: I am still very new to rails and ruby both [about 4 days to be exact] so please excuse me if this is an obvious mistake. I thought I had got the use of validates... right until I tried to use validates_uniqueness_of My setup for testing: I have a simple users table in mysql with the normal primary key ''id'' and a field ''username'' I include the line validates_uniqueness_of :username, :message => ''That username is already taken, please try again'' in the User class and try it out. It does raise a validation message when I try and use an existing username on either edit or new records but, and this is what has me confused, it does it twice. e.g. I get the error block at the top of the form using <%= error_messages_for ''user'' %> but it says there are two errors in the form and repeats the above error message for both descriptions. Aside from that I only have the one validation rule on this table at the moment. Does anyone have any ideas what I may be doing wrong please or is this a known problem. A quick scan through the list archives and I could not see this covered [sorry if I missed an existing explanation] Thanks Huw
Ah, thanks for the info and pointer to the fix I never thought to check the bugs list - I will remember to do this in future :) Huw>see: http://dev.rubyonrails.com/ticket/971 > > > >>Hi list >> >>First a brief disclaimer: I am still very new to rails and ruby both >>[about 4 days to be exact] so please excuse me if this is an obvious >>mistake. I thought I had got the use of validates... right until I tried >>to use validates_uniqueness_of >> >>My setup for testing: I have a simple users table in mysql with the >>normal primary key ''id'' and a field ''username'' >> >>I include the line >> >> validates_uniqueness_of :username, :message => ''That username is >>already taken, please try again'' in the User class and try it out. >> >>It does raise a validation message when I try and use an existing >>username on either edit or new records but, and this is what has me >>confused, it does it twice. >> >>e.g. I get the error block at the top of the form using >> >><%= error_messages_for ''user'' %> >> >>but it says there are two errors in the form and repeats the above error >>message for both descriptions. Aside from that I only have the one >>validation rule on this table at the moment. >> >>Does anyone have any ideas what I may be doing wrong please or is this a >>known problem. A quick scan through the list archives and I could not >>see this covered [sorry if I missed an existing explanation] >> >>Thanks >>Huw >> >> > > > >
see: http://dev.rubyonrails.com/ticket/971> Hi list > > First a brief disclaimer: I am still very new to rails and ruby both > [about 4 days to be exact] so please excuse me if this is an obvious > mistake. I thought I had got the use of validates... right until I tried > to use validates_uniqueness_of > > My setup for testing: I have a simple users table in mysql with the > normal primary key ''id'' and a field ''username'' > > I include the line > > validates_uniqueness_of :username, :message => ''That username is > already taken, please try again'' in the User class and try it out. > > It does raise a validation message when I try and use an existing > username on either edit or new records but, and this is what has me > confused, it does it twice. > > e.g. I get the error block at the top of the form using > > <%= error_messages_for ''user'' %> > > but it says there are two errors in the form and repeats the above error > message for both descriptions. Aside from that I only have the one > validation rule on this table at the moment. > > Does anyone have any ideas what I may be doing wrong please or is this a > known problem. A quick scan through the list archives and I could not > see this covered [sorry if I missed an existing explanation] > > Thanks > Huw