Victor Cisneiros wrote in post #969792: > I have a table 'client' with a unique index on column 'nome' > I have also set validates :uniqueness => true on column 'nome' > > There is a record 'João Victor Santos' on my clients table. When I try > to insert another 'João Victor Santos' Rails executes the following > command to check if a record with this name already exists: > > SELECT `clients`.`id` FROM `clients` WHERE (`clients`.`nome` = BINARY > 'João Victor Santos') LIMIT 1 > > Unfortunately this query returns 0 rows and validation passes and I > receive this stack trace > > Mysql::Error: Duplicate entry 'João Victor Santos' for key 2 > > If I execute this query in phpMyAdmin it correctly returns 1 result > > SELECT `clients`.`id` FROM `clients` WHERE (`clients`.`nome` = 'João > Victor Santos') LIMIT 1
Perhaps you've got an encoding issue. > > I'm using Rails 3.0.3, Ruby 1.8.7 and the mysql gem. I can't switch to > mysql2 gem because I'm running on Windows and this application will also > run on Windows in production You should absolutely not be running Rails applications on Windows in production. Find a way to host the app on *nix if at all possible. > > Has anyone faced this problem? Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org Sent from my iPhone -- 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-t...@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.