<  February 2017   >
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28
00:49 mwlang joined
01:01 mwlang joined
01:13 mwlang joined
02:33 jeremyevans joined
02:38 mwlang joined
03:08 jeremyevans joined
06:59 mwlang joined
07:11 mwlang joined
07:23 mwlang joined
09:52 banditron joined
09:55 mwlang joined
10:07 mwlang joined
12:21 ta joined
13:16 contradictioned joined
15:20 mwlang joined
15:40 mwlang joined
16:11 Bish joined
16:11 <Bish> o/
16:12 <Bish> is it clever / can i overload .save/.update in a way, where this happens on 2 databases with prepared transactions transparently?
16:14 <Bish> so i can get that "on both or nowhere" behaviour
16:14 <Bish> or is there something more clever that i can do
16:14 <Caesium> http://sequel.jeremyevans.net/rdoc/files/doc/transactions_rdoc.html#label-Prepared+Transactions+-2F+Two-Phase+Commit
16:14 <Bish> Caesium: i know that, i used it already, my question is over other nature
16:16 <Bish> s/over/of
16:16 <Caesium> well, you can always define around_save, then its just up to you whether you call super or not, I suppose
16:16 <Bish> isn't around save just a hook?
16:16 <Caesium> yeah
16:17 <Bish> well, if i am hooking, i cannot do both "at the same time" one has to be first always, doesn't it?
16:17 <Bish> i never understood how the around_* hooks worked
16:17 <Bish> could you explain to me, how i would to that correctly? i even have thought about it, but can't figure it out
16:18 <Bish> my current approach was overloading .create (for example)
16:18 <Bish> it works, pretty okay
16:18 <Caesium> what does your overload look like?
16:18 <Bish> i will paste the relevant parts, one moment
16:18 <Bish> be warned, i use tabs
16:20 <Bish> https://gist.github.com/anonymous/28d605f905347535c7ecdc10fe96664f
16:21 <Bish> this is not the final version, so have mercy
16:22 <Bish> im suprised this worked and impressed
16:22 <Bish> but would love if there was a more sophisticated way to do that
16:22 <Bish> since i will have to do that with 2-4 models
16:22 <Bish> where all updates/creations have to be reflected to another db
16:59 <Bish> i don't quite understand how the around hooks help me with that :(
18:35 AYGHOR joined
19:24 <jeremyevans> Bish: You need to add a rescue block that rollsback the prepared transaction on error, and move the commit_prepared_transaction to an ensure block (only execute if no error)