Here''s my method that has the transaction in it: http://rafb.net/paste/results/yIuwpz49.html The message, forumobject and groupright are all models within the same database. I have some validations for each and my problem is that when the validation for message fails, other objects still get saved. Why is this happening? -- 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 -~----------~----~----~----~------~----~------~--~---
On Wed, Oct 11, 2006 at 04:51:07PM +0200, RoR newbie wrote: } } Here''s my method that has the transaction in it: } http://rafb.net/paste/results/yIuwpz49.html } } The message, forumobject and groupright are all models within the same } database. } } I have some validations for each and my problem is that when the } validation for message fails, other objects still get saved. } } Why is this happening? Without actually seeing your code, my guess is that you are using MySQL with MyISAM tables, which do not support transactions. Insert rant here about how MySQL is a lousy RDBMS. --Greg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You need to use the .save! method which throws an exception, or generate your own exception if there''s an error. Transactions only roll back on an exception. On Oct 11, 2006, at 7:51 AM, RoR newbie wrote:> > Here''s my method that has the transaction in it: > http://rafb.net/paste/results/yIuwpz49.html > > The message, forumobject and groupright are all models within the same > database. > > I have some validations for each and my problem is that when the > validation for message fails, other objects still get saved. > > Why is this happening? > > -- > Posted via http://www.ruby-forum.com/. > > >-- -- Tom Mornini --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Tom Mornini wrote:> You need to use the .save! method which throws an exception, > or generate your own exception if there''s an error. Transactions > only roll back on an exception. >Can this be done so that it won''t give me the exception screen but justs rolls back and goes on? -- 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 -~----------~----~----~----~------~----~------~--~---
RoR newbie wrote:> Tom Mornini wrote: >> You need to use the .save! method which throws an exception, >> or generate your own exception if there''s an error. Transactions >> only roll back on an exception. >> > > Can this be done so that it won''t give me the exception screen but justs > rolls back and goes on?If you catch the exception in a rescue block and do nothing, yes. -- 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 -~----------~----~----~----~------~----~------~--~---
On Oct 11, 2006, at 2:06 PM, RoR newbie wrote:> Tom Mornini wrote: >> You need to use the .save! method which throws an exception, >> or generate your own exception if there''s an error. Transactions >> only roll back on an exception. >> > > Can this be done so that it won''t give me the exception screen but > justs > rolls back and goes on?Yes. That is a given when wrapped in a transaction. -- -- Tom Mornini --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---