 Baiklah, saya fikir pakaian yang akan terjadi hari ini adalah kerana kita tidak dapat sesiapa-siapa lakukannya lakukannya Sebenarnya, ia telah melakukannya beberapa jam sebelum saya datang ke sini Pertama, saya sedang menyebabkan obyek sen Maksudnya, apabila anda mahu menyebabkan metode, anda boleh menyebabkan sen atau obyek Mereka boleh menyebabkan metode Tetapi sen menyebabkan metode pribadi juga Jadi, jika saya melakukannya sesetengah kadang-kadang dalam test saya Meskipun, kita tidak menyebabkan Maksud saya, beberapa orang akan mengatakan bahawa anda tidak menyebabkan metode pribadi Tetapi, pada beberapa kes saya membuat, saya menggunakan sen Tetapi, jika anda menyebabkan Anda ingin memastikan bahawa sen tidak menghiaskan metode pribadi Anda menggunakan sen public Jadi, sen public saya memastikan bahawa ia menggunakan metode public Ini adalah pula 2 Okey, saya sedang menyebabkan Ya, sebenarnya, dalam Ruby 2.3, mereka menggunakan hash toad Anda dapat menggunakan sesuatu seperti Anda menggunakan hash pembentangan, pencet, dan penjaman Anda dapat membuat dari pula Anda dapat menggunakan pembentangan dana Anda dapat menghias pembentangan dana Anda akan menggunakan Kali, sim, dan sebagainya Yang mana? Yang yang dipercayai Jadi, apa yang ia membuat membuat menggunakan hash pembentangan Dan kemudian, apabila menangkap So basically it calls to prompt pricing and then it will prompt.call the key of the actual can do something like that. So tip number 3 is actually something related to some stuff that I did recently. So basically my task was to create a four-back adapter for Postgres. So we run like a master server and a replica server. So let's say if the master server is down, we want to four-back gracefully into the replica server. So I don't think we can do it at low-density, through Postgres or something like that. But we didn't want it at that level. We wanted it at that level so that we reduce the complexity of handling it at a system like that. So basically this is not documented but this is like something I discovered. It's supposed to be public API so I don't know why it's not documented. So let's say if you declare in your database a demo, your adapter, you can call anything. In my case, Postgres four-back. So what will happen is that every connection you actually call, let's say you define an active record connection handling and you define like Postgres under your adapter name underscore connection and then it receives a config. You can do a bunch of storage. So in this case, I'm calling like, you can actually call the Postgres 12 connection. They are all clad in the module itself. So I can get a connection. So, okay, this block is from, the connection is supposed to be inside the game block. Anyway, you can rescue, let's say if your master service is down for some reason, you can rescue from it and then you can do funny things like I can pass it a different config and then I'll connect to my replica server. So it's pretty interesting. There's a lot of things you can do with it. In our case, basically, what we did was we rescued from it. We set our, so we discuss runs forum, so we have a read-only mode. We set our discuss forum to read-only mode and then we start a long running track that keeps paying the master server every 5 seconds. Are you up? So it's actually pretty interesting like we get to do, we get upgrade the database where often nowadays we just kill the master server, boot up a new container for it and then decide send me down for like 5 seconds or so. Instead of down, it's a read-only mode for 5 seconds. So it's pretty interesting. The tip number 4 is like in Ruby 2.3.0, you get positive and negative. So it initially I was like, why in the world do you need this method? It's like number of characters versus greater than zero, less than zero. So that's what I thought, why in the world do you need this? How does it work on zero? It's false all the time. It's false. So initially I was like, why in the world do you need it? So we just edit it first and then they proposed it to Ruby. Then Ruby merged it in. But I guess something interesting that you can do like M% then pass in symbol positive. I don't know. I'm not really a big fan of it. I'd rather just do like something like that if I'm not wrong, it's less characters to type. Ya, there is kind of I have no idea why we need this kind of methods. Ya, this one is controversial. I hate this. So it's actually World's Five is coming. This and World's Five. Ya, it's like so you have second to last it gives you the item second from the last. As compared, you can just do negative to index. So then there's third to last. I don't know, maybe you can add fourth to last, fifth to last. Ya, so I don't agree with the array part but I guess it could be useful in terms of active record in... what's the thing with that? Basically you can do user.second to last you actually do the offset and limits for you. So I guess that could be useful but then Rails has a method user.42 It's a real method. You return it to 42 for the second record in your user in this case. So we have one in Rails, if you look under one of the files we have one first, second, third, fourth, fifth then it's 42 so perhaps you'll get second to last third to last, then 42 to last. Ya, that's just so fun. Ya, so that's all for my five random Ruby tips. Eh, doesn't that have any questions? Ya, the first press it's a bit rough. So what happens so if my understanding is correct I'm still a bit new to what happens underneath so let's say if you queue your master server so your current connection in the connection pool will be lost so when that happens Rails internally will try to connect again to the server itself so there will be a connection in the connection pool so when that happens again to the server itself so that's where this part comes in so you definitely get an exception a few users will get an exception that they'll get the connection to the server it's lost, something like that and then you fall back so in this rescue part you can actually do a bunch of stuff that you want. So you're still meeting one master postgres? Correct, one master postgres so actually record a bit of a dive want to go into it and then we'll go into what is and more questions it seems to put your host and the pod in the actual adapter code do you put actual code there as in the config or do you grab it from the YAMO oh okay so let's put it in the YAMO so actually this will be like config graphical so we'll be added in there ourselves so the connection should be inside the game block so it can rescue it this code will never work sorry for us to put it in initialiser so if you require this file before you put up your real set so you can put it in initialiser and then you can find F2, did you say almost like it's read-only? Ya, so it's internally we have some code that enables us to set outside the read-only mode so you can't go into update or any update varies to the database because you're reading from a slave, right? Yes, correct actually when you read from a slave it's automatically you can't do update because it's recovery so you can't go into update at all I guess that's all Ya, so PR for 40 seconds to last second Oh, I'm not cat Ya, so we've come to the end of the talk so if anyone want to hide so it's like if you're hiring, get one say few stuff