I am getting a mysql duplicate entry error. Can I ignore the error (let the script continue), and how would I do that? Or should I check if the entry exists every time, before I try to add it? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
One solution I figured out is to enclose the offending line in
begin
do_something_that_causes_an_error.here
rescue
end
I was afraid it was going to take me a while to fix this, but it was
easier than I expected.
I am really starting to like Ruby.
It works, however is seems messy.
Is there a better way to do this?
On Apr 16, 2:50 pm, cumom
<peteri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I am getting a mysql duplicate entry error.
>
> Can I ignore the error (let the script continue), and how would I do
> that?
>
> Or should I check if the entry exists every time, before I try to add
> it?
--~--~---------~--~----~------------~-------~--~----~
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 Apr 16, 3:50 pm, cumom <peteri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am getting a mysql duplicate entry error. > > Can I ignore the error (let the script continue), and how would I do > that? > > Or should I check if the entry exists every time, before I try to add > it?If you are using Rails properly with an auto_increment id column, this shouldn''t happen. And inserting a duplicate row in a DB is usually a very serious problem. You should not ignore it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---