Dear ALL" I would like to ask, what is it true that rails already supports transaction although we do not put ActiveRecord::Base.transaction in our ruby controller or model script? - My DB ENGINE is InnoDB - I did test in web browser with putting delay process inside of script to make 2 concurrent process having collision, but the fact at final, they are handled with transaction, i do not put any ActiveRecord::Base.transaction or ModelName.transaction script there. Example : They are 10 items in stock. 2 concurrent process wanted to take 1 item from stocks. If it is not having ActiveRecord::Base.transaction in method the result would be 9, but the fact is it is 8 (10-1-1). Look the tables process below without transaction in console (table 1) & web browser (table 2): http://pastie.caboo.se/194711 How come my test in console and web browser are difference ?? -- 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 10 May 2008, at 05:06, Rails Terrorist wrote:> > Dear ALL" > > I would like to ask, what is it true that rails already supports > transaction although we do not put ActiveRecord::Base.transaction in > our > ruby controller or model script? - My DB ENGINE is InnoDB - >I''m not quite sure what you''re asking, but rails does wrap the validation, before_save, save and after_save sequence in a transaction.> I did test in web browser with putting delay process inside of > script to > make 2 concurrent process having collision, but the fact at final, > they > are handled with transaction, i do not put any > ActiveRecord::Base.transaction or ModelName.transaction script there. > > Example : > They are 10 items in stock. 2 concurrent process wanted to take 1 item > from stocks. If it is not having ActiveRecord::Base.transaction in > method the result would be 9, but the fact is it is 8 (10-1-1). Look > the > tables process below without transaction in console (table 1) & web > browser (table 2): > > http://pastie.caboo.se/194711 > > How come my test in console and web browser are difference ??If you''re just running a single mongrel/webrick instance then when you test with your browser you''re not actually executed 2 things at the same time (since a rails instance only handles one request at a time). Fred (PS: if you want to insert a delay, the sleep method is rather handier than counting to a million) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
My Fred Brother thank you for your answer. Sleep mode is good idea and also you give me information about :>If you''re just running a single mongrel/webrick instance then when you >test with your browser you''re not actually executed 2 things at the >same time (since a rails instance only handles one request at a time).I test : I open 2 web browser and do concurrent process by accessing the same method for adding 1 item to cart, but it looks like having transaction in my method, whereas I do not put ActiveRecord::Base.transaction there. Since you explained above, now i understand why my concurent process looks like having transaction, because it handles one request at a time and other can only follow. Thank you, Reinhart http://teapoci.blogspot.com -- 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 -~----------~----~----~----~------~----~------~--~---