begin ActiveRecord::Base.transaction do . . raise 'ãã¼ã«ããã¯ãã¾ã' end p 'ã³ããã' # ãã©ã³ã¶ã¯ã·ã§ã³å¦çãç¢ºå® rescue => e p 'ãã¼ã«ããã¯' # ãã©ã³ã¶ã¯ã·ã§ã³å¦çãæ»ã end transactionãããã¯ã®ä¸ã§ç»é²ã»æ´æ°å¦çãè¡ãå ´åã¯ãsaveãupdateã§ã¯ãªããsave!, update!ã使ç¨ããã transactionãããã¯ã®ä¸ã§è¤æ°ã®ã¢ãã«ã®æ´æ°ãè¡ã£ãå¾ã«ä¾å¤ãçºçãããã¨ãå ¨é¨ã®ã¢ãã«ããã¼ã«ããã¯ããã 楽観çãã㯠ã競åã¯å¤åèµ·ããªãã ãããã¨ããåæã§ããã¼ã¿ã®åå¾æã«ã¯ä½ããããæ´æ°æã«ç«¶åããã§ãã¯ããæ¹æ³ã ã¬ã³ã¼ãã®ãã¼ã¸ã§ã³ç®¡çãè¡ãããããã¼ãã«ã«lock_versionã«ã©ã ã追å ããããã®éãããã©ã«ãå¤ã0ã«ããã lock_versionã¯ã¬ã³ã¼ã
{{#tags}}- {{label}}
{{/tags}}