« Back to channel list

#RubyOnRails - 26 April 2018

« Back 1 day Forward 1 day »
[00:21:07] workmad3: has joined #RubyOnRails
[00:36:44] mjolnird: has joined #RubyOnRails
[00:44:11] Linuus: has joined #RubyOnRails
[00:47:33] K4L1: has joined #RubyOnRails
[00:49:24] Technodrome: has joined #RubyOnRails
[00:51:38] K4L1: Hello, im following the Rails guide and i have a trouble when start the server, can someone here help me? https://imgur.com/a/xJ4TjjX
[00:54:04] orbyt_: has joined #RubyOnRails
[01:01:31] LateralO1: has joined #RubyOnRails
[01:10:21] sevenseacat: has joined #RubyOnRails
[01:15:14] alfiemax: has joined #RubyOnRails
[01:32:14] eckhardt: has joined #RubyOnRails
[01:37:22] nickenchuggets: has joined #RubyOnRails
[01:41:55] alfiemax: has joined #RubyOnRails
[01:53:14] Linuus: has joined #RubyOnRails
[02:06:57] cagmz: has joined #RubyOnRails
[02:07:27] alfiemax: has joined #RubyOnRails
[02:08:16] cpruitt: has joined #RubyOnRails
[02:08:58] Kilobyte22: has joined #RubyOnRails
[02:09:01] auv5: has joined #RubyOnRails
[02:14:14] shtirlic: has joined #RubyOnRails
[02:15:26] cgfbee: has joined #RubyOnRails
[02:15:36] TheMoonMaster: has joined #RubyOnRails
[02:16:21] Saukk: has joined #RubyOnRails
[02:17:22] _3dwardsharp: has joined #RubyOnRails
[02:17:58] _aeris_: has joined #RubyOnRails
[02:19:57] Technodrome: has joined #RubyOnRails
[02:20:44] workmad3: has joined #RubyOnRails
[02:27:33] orbyt_: has joined #RubyOnRails
[02:32:04] Linuus: has joined #RubyOnRails
[02:32:27] cpruitt: has joined #RubyOnRails
[02:45:50] cpruitt: has joined #RubyOnRails
[02:47:51] fcser__: hmm there must be a simple way… I just want to see or log the current layout name…
[02:58:19] fcser__: ok nm it’s logged by default in console… “Rendering controller_name/action.html.erb” within layouts/layout_name
[03:02:01] nickjj: has joined #RubyOnRails
[03:03:49] cpruitt: has joined #RubyOnRails
[03:08:06] Linuus: has joined #RubyOnRails
[03:08:21] matcouto: has joined #RubyOnRails
[03:27:43] AntiSpamMeta: has joined #RubyOnRails
[03:29:40] cpruitt: has joined #RubyOnRails
[03:35:57] cpruitt: has joined #RubyOnRails
[03:37:51] alfiemax: has joined #RubyOnRails
[03:44:32] alfiemax: has joined #RubyOnRails
[03:47:49] cagomez: has joined #RubyOnRails
[03:48:53] tejasmanohar: has joined #RubyOnRails
[03:52:01] Linuus: has joined #RubyOnRails
[03:52:23] woohoou: has joined #RubyOnRails
[03:53:18] LateralO1: has joined #RubyOnRails
[03:58:49] orbyt_: has joined #RubyOnRails
[03:59:08] alfiemax: has joined #RubyOnRails
[04:06:09] cagomez: has joined #RubyOnRails
[04:19:01] workmad3: has joined #RubyOnRails
[04:20:00] hfp_work: has joined #RubyOnRails
[04:28:22] Linuus: has joined #RubyOnRails
[04:30:44] cpruitt: has joined #RubyOnRails
[04:35:30] kapil___: has joined #RubyOnRails
[04:52:59] cpruitt: has joined #RubyOnRails
[04:56:26] Technodrome: has joined #RubyOnRails
[05:07:51] Linuus: has joined #RubyOnRails
[05:13:29] moei: has joined #RubyOnRails
[05:14:36] hfp_work: has joined #RubyOnRails
[05:16:06] timdotrb_: has joined #RubyOnRails
[05:18:46] mjolnird: has joined #RubyOnRails
[05:20:54] cpruitt: has joined #RubyOnRails
[05:23:06] reber: has joined #RubyOnRails
[05:30:43] srinidhi: has joined #RubyOnRails
[05:40:49] apeiros: has joined #RubyOnRails
[05:50:34] Linuus: has joined #RubyOnRails
[06:17:59] workmad3: has joined #RubyOnRails
[06:18:49] cpruitt: has joined #RubyOnRails
[06:21:19] cpruitt: has joined #RubyOnRails
[06:22:03] MrCrackPotBuilde: has joined #RubyOnRails
[06:22:43] Linuus: has joined #RubyOnRails
[06:25:11] jackhum: has joined #RubyOnRails
[06:29:50] conta: has joined #RubyOnRails
[06:38:38] cpruitt: has joined #RubyOnRails
[06:45:07] Technodrome: has joined #RubyOnRails
[06:55:08] LateralO1: has joined #RubyOnRails
[07:01:14] Linuus: has joined #RubyOnRails
[07:12:10] conta1: has joined #RubyOnRails
[07:18:20] dionysus69: has joined #RubyOnRails
[07:38:03] moei: has joined #RubyOnRails
[07:38:51] defsdoor: has joined #RubyOnRails
[07:41:36] conta: has joined #RubyOnRails
[07:41:43] Linuus: has joined #RubyOnRails
[07:50:21] cpruitt: has joined #RubyOnRails
[07:51:24] jottr: has joined #RubyOnRails
[08:04:07] srinidhi: has joined #RubyOnRails
[08:07:50] Ergo: has joined #RubyOnRails
[08:16:54] workmad3: has joined #RubyOnRails
[08:20:40] cpruitt: has joined #RubyOnRails
[08:23:48] ellcs: has joined #RubyOnRails
[08:25:13] Linuus: has joined #RubyOnRails
[08:25:32] lunarkitty7: has joined #RubyOnRails
[08:26:46] jackhum: has joined #RubyOnRails
[08:27:43] deathwishdave: has joined #RubyOnRails
[08:31:07] dionysus69: should puma workers match number of vCores on the VM or can be more?
[08:31:22] dminuoso: dionysus69: You can safely have much more.
[08:31:30] dionysus69: I read that it could be set to 6 on 4 core machine, but I don't understand what benefit would that give
[08:31:38] dminuoso: dionysus69: In normal cases you will be I/O bound, so..
[08:33:10] dionysus69: has joined #RubyOnRails
[08:33:16] conta: has joined #RubyOnRails
[08:33:37] dionysus69: sorry dminuoso my pc froze had to powercycle
[08:33:47] dionysus69: did you write me anything after my second message ? :D
[08:33:59] dminuoso: 10:31 dminuoso | dionysus69: In normal cases you will be I/O bound, so..
[08:34:21] dionysus69: do you mean disk IO ?
[08:34:57] dminuoso: dionysus69: Kind of depends really on your app in the end, but usually you will spend a lot of time waiting on the database.
[08:34:58] dionysus69: I see, so if I set 6 processes on 4 core machine, that sounds about right? with 8 gb ram
[08:35:15] dminuoso: dionysus69: So when those threads block waiting on the database the GVL is released and other threads can run.
[08:35:26] dionysus69: once I will have time to optimize app I am planning to move db on different VM altogether
[08:35:28] DrYockel: has joined #RubyOnRails
[08:35:51] dminuoso: dionysus69: That will increase the amount of blocking IO on the database if you move them onto a different VM.
[08:37:17] dionysus69: latency will increase by a bit but disk IO throughput will also increase
[08:37:19] dminuoso: Oh wait you asked about workers
[08:37:47] dionysus69: yea, each process defaults to 5 threads, I am not touching that part
[08:37:49] dminuoso: dionysus69: It's hard to say and depends on what your app does really. I'd recommend you scale up and monitor performance characteristics
[08:38:23] dminuoso: dionysus69: 5 threads is not a lot..
[08:38:41] dminuoso: dionysus69: the default of 16 threads per pool is pretty good
[08:38:47] dionysus69: I see, so far I have plenty of available RAM on the machine so I want to make it use more
[08:38:55] dionysus69: per pool, meaning per db right?
[08:38:55] lunarkitty7: has joined #RubyOnRails
[08:39:01] dminuoso: no per puma thread pool.
[08:39:44] dionysus69: hmm ok, I dont really understand the idea of green threads, if they can't run in parallel, can't see application for them :S
[08:40:03] dionysus69: so whether it can be 5 or 16, I dont know what practical difference it would give to the app
[08:40:26] dminuoso: dionysus69: They can run parallel if they are blocking on IO
[08:41:02] dionysus69: what do you mean if they are blocking IO ?
[08:41:10] dminuoso: dionysus69: Do you know how IO works?
[08:41:33] dionysus69: well, process gives a request and next request has to wait until the first one is done
[08:41:39] dionysus69: that's what I know :D
[08:42:20] dionysus69: but if I am having let's say 6 processes/workers, what more can extra threads do? those workers will most likely exhaust IO throughout
[08:42:38] dminuoso: dionysus69: So when you do some network request you have to talk to the kernel.
[08:42:55] dminuoso: dionysus69: You can do this in a blocking fashion, that means your execution thread will be *paused* until the requested data is available
[08:43:55] dminuoso: dionysus69: Puma uses not green threads but native threads by the way.
[08:43:58] dionysus69: so until one thread is paused another one is working I assume right?
[08:44:11] dminuoso: dionysus69: Well the kernel works like this:
[08:44:16] dionysus69: oh, puma sounds cool then :D
[08:45:00] dminuoso: dionysus69: thread A is executing. Then thread A requests some data from a TCP socket from the kernel (blocking). Now execution takes places in the kernel.
[08:45:13] dminuoso: The kernel sees that the data is not available, so it has to wait. Maybe the data have not been sent over the wire.
[08:45:42] dminuoso: The thread A is then halted, it will not be resumed until the data is available. Now the CPU is idle, so the kernel finds another thread to execute.
[08:46:00] dminuoso: It sees that thread B hasn't been run for a time, and then it runs thread B.
[08:46:38] dminuoso: Until thread B makes a call into the kernel again (in which case the kernel will check whether data for `thread A` has arrived. If so, it will resume `thread A`, otherwise it will find another thread to run.
[08:47:27] dminuoso: And this kind of dance is whats happening under your hood tens of thousands of times per second in your computer. =)
[08:47:42] dionysus69: I suppose so xD
[08:48:03] dminuoso: dionysus69: So "blocking IO" essentially means the thread is put to sleep until the data is available. No CPU times are wasted.
[08:48:08] dionysus69: being a web dev is cool, you need to know more than little bit of everything :D
[08:48:18] dminuoso: dionysus69: Ruby now guarantees that on syscalls the GVL is released.
[08:48:37] dminuoso: So if one thread is "waiting on something from the kernel", another ruby thread can run in parallel.
[08:48:45] dionysus69: GVL is same as GIL right?
[08:48:54] dminuoso: GIL is the old name. we no longer have an interpreter.
[08:49:00] dminuoso: We have a VM now, so its called GVL ;)
[08:50:05] dionysus69: I was listening Matz on topic of threads and he said it was hard to program real threads, I stopped asking questions about threads after that :D
[08:50:36] dionysus69: as in, he was explaining why the GVL exists
[08:50:48] dminuoso: Well Ruby was not designed or built with concurrency/parallesim in mind.
[08:51:08] dminuoso: In very short terms: The GVL prevents the Ruby VM from getting corrupted.
[08:51:19] dminuoso: that is, it ensures Ruby wont segfault if you use threads.
[08:51:42] dminuoso: Which is a rather useless guarantee for actual developers..
[08:51:58] dminuoso: (Mostly because you expect that anyway)
[08:53:08] dionysus69: ye I imagine it is hard to make operations on data with multiple processes, but that's why it's rewarding too
[08:53:20] dang`r`us: broadly speaking, threads are often the wrong abstraction
[08:53:23] dang`r`us: (too low level)
[08:53:39] tbuehlmann: dionysus69: when using puma, I use n workers for n cores. then just adjust threads to a good number
[08:54:39] dionysus69: do you go up to as high as 16 threads per worker? as dminuoso suggested ? :P
[08:54:42] lunarkitty7: has joined #RubyOnRails
[08:55:11] dminuoso: dionysus69: dont fix them. puma can rescale according to load.
[08:55:12] tbuehlmann: that depends on some things
[08:55:13] dionysus69: in that case I would have to also set the database connection pool number at 16 too btw right?
[08:55:21] dminuoso: dionysus69: Honestly my suggestion is: try it out
[08:55:39] tbuehlmann: yes, you probably need a database connection per thread
[08:55:58] tbuehlmann: if you have a hard limit on db connections, don't go over that number
[08:55:59] dionysus69: so does it mean database.yml has to have 16 or 4x16 ?
[08:56:13] deathwishdave: has joined #RubyOnRails
[08:56:19] tbuehlmann: each puma worker gets its own db connection pool
[08:56:21] dminuoso: again it depends though
[08:56:31] dionysus69: thanks allot, still lot to do/learn in these waters
[08:56:33] tbuehlmann: sure, just explaining the calcs
[08:56:40] dminuoso: if some of your app does not use that database, you can have more threads.
[08:56:59] tbuehlmann: right, that's why I wrote "probably". but I assume that'll be the case
[08:57:11] dminuoso: ACTION pokes tbuehlmann with a strong profunctor
[08:57:41] tbuehlmann: is there are a Probably, like there is a Maybe?
[08:57:53] dminuoso: There is a Perhaps now.
[08:58:52] dionysus69: btw, if you have more time I have lot more questions, one of them is regarding preload_app! and on_worker_boot do establish_connection
[08:59:56] dionysus69: so let's say I set n workers and m threads, and enable preload_app, I was reading about copy_on_write thing, any more considerations I need to account for?
[09:00:33] dionysus69: will I get data corrupted or data inconsistency between threads or processes or any of that sort?
[09:01:29] LateralO1: has joined #RubyOnRails
[09:01:35] Linuus: has joined #RubyOnRails
[09:01:44] tbuehlmann: when using preload_app, puma will load your rails application and then spawn workers. these worker will then use the already loaded application instead of loading it
[09:02:22] dionysus69: I know it deals with cutting memory usage down by sharing it, I am just interested in it because if it creates extra problems, maybe it's not worth dealing with it
[09:02:23] tbuehlmann: that's the basic idea. CoW will save you some memory when loading the application before spawning workers
[09:02:38] tbuehlmann: no extra problems
[09:02:44] dionysus69: oh cool then
[09:02:53] tbuehlmann: "no extra problems"
[09:03:06] deathwishdave: has joined #RubyOnRails
[09:03:07] tbuehlmann: calculating memory used might be harder because some of it is shared now
[09:04:17] tbuehlmann: and you cannot use phased restarts anymore
[09:04:37] dionysus69: it's fine, DO offers lots of memory for cheap xD I am also planning implement lots of caching in app and put a shared redis server among possibly 1+ app servers
[09:04:46] dionysus69: phased restart is??
[09:05:24] dminuoso: Something for you to google.
[09:05:38] tbuehlmann: I highly recommend reading the puma readme as well
[09:06:21] dminuoso: Oh and I highly recommend a banana lasagne.
[09:07:00] dionysus69: how do you deal with env vars, do you set them in OS or have you moved all of them in 5.2 credentials? even vars like this WEB_CONCURRENCY
[09:07:18] tbuehlmann: a US coworker brought "banana bread" some time ago and it wasn't bread, it was cake. it was a lie all along
[09:07:49] dionysus69: lol yea I have seen those in starbucks xD
[09:07:50] sevenseacat: ACTION shoots the spy
[09:08:17] tbuehlmann: dionysus69: depends on your deployment strategy I guess. when using heroku, I prefer environment variables all the way. when deploying via capistrano, config from files all the way
[09:08:37] dionysus69: yea I use capistrano
[09:13:07] tbuehlmann: I personally don't use rails credentials yet, since they are not per environment, which is really weird
[09:13:25] tbuehlmann: the "old" secrets still work, so I'd use them
[09:14:31] dionysus69: I have read an article online that explained how to use them with environment
[09:14:42] dionysus69: it shouldn't be hard to setup
[09:14:47] tbuehlmann: yeah, you could also just have them as keys, but naw
[09:14:59] tbuehlmann: there are also gems for that
[09:15:15] dionysus69: with encryption?
[09:15:23] tbuehlmann: but I mean, you're using capistrano, symlinking a config is easy
[09:15:44] alfiemax: has joined #RubyOnRails
[09:15:56] dionysus69: yea but instead of going into server and changing config you could change config locally and cap deploy
[09:16:45] dionysus69: which is just so much cooler xD
[09:17:19] tbuehlmann: also, share the master key with your colleagues over some kind of secure channel
[09:17:51] dionysus69: yea I guess :D
[09:19:21] apeiros: has joined #RubyOnRails
[09:25:34] deathwishdave: has joined #RubyOnRails
[09:33:58] dionysus69: https://ibb.co/jFkHWx so this is what htop shows for puma
[09:34:25] dionysus69: I have specified 5 threads but there are 6, do you know what the sixth one is for ?
[09:35:07] AntiSpamMeta_: has joined #RubyOnRails
[09:35:33] dminuoso: dionysus69: puma will spawn additional threads for internal purposes.
[09:36:03] dminuoso: dionysus69: One common case is to provide a bit of elastic behavior when you get clients behind shitty connections.
[09:37:33] dionysus69: ah I see, thanks again :)
[09:38:15] defsdoor_: has joined #RubyOnRails
[09:41:26] workmad3: has joined #RubyOnRails
[09:44:32] cabotto: has joined #RubyOnRails
[09:52:44] schneider: has joined #RubyOnRails
[09:53:37] apeiros__: has joined #RubyOnRails
[10:07:19] alfiemax: has joined #RubyOnRails
[10:12:00] Linuus: has joined #RubyOnRails
[10:17:08] ellcs: has joined #RubyOnRails
[10:18:41] workmad3: has joined #RubyOnRails
[10:28:43] ikbenhet: has joined #RubyOnRails
[10:31:05] conta: has joined #RubyOnRails
[10:31:40] deathwishdave: has joined #RubyOnRails
[10:34:54] dionysus69: has joined #RubyOnRails
[10:37:18] kapil___: has joined #RubyOnRails
[10:37:18] srinidhi: has joined #RubyOnRails
[10:54:29] Linuus: has joined #RubyOnRails
[10:56:17] conta: has joined #RubyOnRails
[10:59:09] cabotto: has joined #RubyOnRails
[11:03:09] Cavallari: has joined #RubyOnRails
[11:15:05] chouhoulis: has joined #RubyOnRails
[11:16:47] dionysus69: I have this line in puma
[11:16:48] dionysus69: workers ENV.fetch("WEB_CONCURRENCY") { 4 }
[11:16:58] dionysus69: and staging environment ignores it altogether
[11:17:05] dionysus69: I have web_concurrency also set to 4
[11:17:15] dionysus69: I only get single puma process without workers
[11:18:05] dionysus69: in console ENV["WEB_CONCURRENCY"] is accessible
[11:19:04] LateralO1: has joined #RubyOnRails
[11:24:24] roshanavand: has joined #RubyOnRails
[11:26:11] ellcs: has joined #RubyOnRails
[11:27:08] rikkipitt: has joined #RubyOnRails
[11:29:36] cabotto: has joined #RubyOnRails
[11:31:23] Linuus: has joined #RubyOnRails
[11:34:03] workmad3: has joined #RubyOnRails
[11:36:56] Terens: has joined #RubyOnRails
[11:40:18] dionysus69: ok I figured it out, pumactl had a wrong puma.rb lol
[11:57:57] DTZUZO: has joined #RubyOnRails
[12:01:35] ellcs: has joined #RubyOnRails
[12:13:17] roshanavand: has joined #RubyOnRails
[12:19:50] roshanavand: has joined #RubyOnRails
[12:30:34] jerematic: has joined #RubyOnRails
[12:31:21] cpruitt: has joined #RubyOnRails
[12:34:51] chouhoulis: has joined #RubyOnRails
[12:35:21] dionysus69: anyone got this issue with capistrano/puma ? when I start puma it daemonizes and then cap puma:stop cannot detect puma running, obviously restarts aren't working either
[12:41:55] dionysus69: pids/puma.state is not getting created
[12:47:05] chouhoulis: has joined #RubyOnRails
[12:49:00] EspenA: has joined #RubyOnRails
[12:55:48] cabotto: has joined #RubyOnRails
[12:56:38] cpruitt: has joined #RubyOnRails
[12:56:40] _cabotto: has joined #RubyOnRails
[13:03:07] sevenseacat: has joined #RubyOnRails
[13:13:58] rfoust: has joined #RubyOnRails
[13:15:41] Linuus: has joined #RubyOnRails
[13:16:22] dblessing: has joined #RubyOnRails
[13:25:43] ellcs: has joined #RubyOnRails
[13:43:41] elcms: has joined #RubyOnRails
[13:50:31] Linuus: has joined #RubyOnRails
[13:55:53] OyoKooN: has joined #RubyOnRails
[13:57:02] dipnlik: has joined #RubyOnRails
[13:58:25] OyoKooN: Hello! I'm using ActiveStorage and try to downlad a picture attached to a model. When I do (in dev), I get the following error: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true. I'm downloading the picture with `Rails.application.routes.url_helpers.rails_blob_path(picture)` where picture is the attachment of my model. How can I make it work?
[13:58:36] broman: has joined #RubyOnRails
[13:59:37] broman: can someone please help me? at some point I'm trying to do this (after_action) session[:my_previous_url] = request.env["HTTP_REFERER"] and from another controller, after a submitted form, I'm trying to redirect_to session[:my_previous_url] when it says Cannot redirect to nil!
[14:00:45] schneider: has joined #RubyOnRails
[14:01:17] OyoKooN: @broman Try with `request.referer` instead of `request.env`
[14:02:21] broman: OyoKooN, thank you for you reply! I'm still getting the same error: "Cannot redirect to nil!
[14:03:03] OyoKooN: Are you actually coming from another page before saving the referer in session?
[14:03:18] OyoKooN: If you just hit reload on this page the referer is nil
[14:03:27] chouhoulis: has joined #RubyOnRails
[14:03:46] OyoKooN: Anyway you should redirect to the session only if it's present and fallback to an other URL otherwise
[14:03:58] broman: after_action :save_my_previous_url, only: [:declaration_go]
[14:04:13] broman: and the body of that method is the request.referer
[14:04:33] broman: so, yes I think.. I'm coming from an actual page
[14:05:41] broman: also, I'm going through the complete path to get there
[14:06:27] OyoKooN: Maybe try to put some logger.debug statements to see what's going on in your methods ;)
[14:08:45] broman: OyoKooN, cannot render console from xxx.xxx.xxx.xxx anything on the configuration file I should change?
[14:10:08] broman: I got it! I was putting it on the wrong controller! Sorry and thank you very much OyoKooN
[14:13:12] OyoKooN: @broman ahah you're welcome
[14:13:50] EXCHGR: has joined #RubyOnRails
[14:27:29] Linuus: has joined #RubyOnRails
[14:33:08] Technodrome: has joined #RubyOnRails
[14:34:25] hays_: has joined #RubyOnRails
[14:37:58] dionysus69: I have an emergency
[14:38:12] dionysus69: when I access puma.sock, I get permission denied
[14:38:25] dionysus69: I get 502 errors from the internet
[14:38:36] dionysus69: but if I launch puma with rails s, it works fine
[14:41:10] hays_: I am calling ActiveRecord::Base.establish_connection in an initialize method of an object. how can I make sure close_connection is called?
[14:42:17] dminuoso: hays_: Don't use initialize in the first place.
[14:42:37] dminuoso: hays_: Rather do it in the style of File.open { ... }
[14:43:10] dminuoso: def self.with_handle(&proc); ActiveRecord::Base.establish_connection; proc.call(); ActiveRecord::Base.close_connection; end;
[14:43:13] dminuoso: Along those lines.
[14:43:56] hays_: hmm. I kind of want the connection to be pretty persistent
[14:44:59] dminuoso: hays_: Well there must be some time when you "lose" that object. Destroy the connection then.
[14:45:01] hays_: (i did not write this code)
[14:45:09] dminuoso: hays_: Either use RAII like I laid out, or do it fully manually.
[14:45:27] hays_: Is ActiveRecord::Base.establish_connection a class method?
[14:45:46] hays_: basically global scope, not object scope? It looks like it
[14:45:57] dminuoso: hays_: Stricly speaking there are no "class methods"
[14:46:16] dminuoso: hays_: establish_connection is a method of the singleton class of the object AR::Base itself.
[14:46:38] hays_: no class methods? at all? isn't that what self.foo is?
[14:47:00] dminuoso: hays_: the concept of "class methods" is a lie designed to ease the transition from other language.
[14:47:19] dminuoso: hays_: formally ruby has only methods. a method lives inside a class.
[14:47:24] dminuoso: Array#length for example lives in Array.
[14:47:52] hays_: alright. and are you saying a class is an object?
[14:48:44] dminuoso: Array.new is a method. To find that, you check the class of "Array" itself
[14:48:56] hays_: so it doesn't make a lot of sense to have an.. erm.. object that isn't a class (not sure what you call that) that invokes this particular method
[14:49:25] dminuoso: hays_: Well let's look generically
[14:49:35] dminuoso: a.b <- in this `a` is the receiver, `b` is the method
[14:49:48] KeyJoo: has joined #RubyOnRails
[14:49:48] dminuoso: arr = [1,2,3]; arr.length
[14:49:56] dminuoso: `arr` is the receiver, `length` is the method
[14:49:59] dminuoso: so far so good?
[14:50:12] hays_: yeah sure i've studied smalltalk a long time ago
[14:50:18] dminuoso: Array.new, `Array` is the receiver, `new` is the method
[14:50:37] dminuoso: So the method lookup in simplified terms works like this:
[14:50:38] hays_: new must call initialize and return an object
[14:50:42] KeyJoo: has joined #RubyOnRails
[14:50:45] dminuoso: maybe, that's really besides the point
[14:51:08] hays_: well its a factory pattern
[14:51:18] dminuoso: point is, `new` is just a message send to `Array`. and there happens to be a _regular_ method behind it :)
[14:51:19] dminuoso: so what class does `new` come from
[14:51:19] dminuoso: when you use arr.length
[14:51:38] dminuoso: it checks arr.class, and looks for a method named length right?
[14:51:50] dminuoso: So `Array.new` does the same thing. It checks Array.class, and looks for a method named length
[14:52:33] dminuoso: hays_: The trick now is, every object has a dedicated singleton class. And the method lookup looks inside that singleton class first.
[14:52:37] hays_: does it? or does it check the methods in whatever new spat out to create the array object
[14:53:13] dminuoso: hays_: `def a.b` for any choice of a, will define a method `b` on the singleton class of `a`
[14:53:24] dminuoso: inside a class definition yuo ahve
[14:53:24] dminuoso: class Foo; def self.bar; ...; end; end
[14:53:25] dminuoso: Inside that context `self` is the class object itself. So `def self.bar` defines a method on the singleton class of the class object itself.
[14:53:35] dminuoso: voila class methods demystified.
[14:54:09] dminuoso: hays_: new is not special.
[14:54:13] dminuoso: hays_: it's just a method like any other
[14:54:34] dminuoso: Kind of got sidetracked though..
[14:54:51] hays_: is it a factory? it doesn't spit out a class, but an instance of the class
[14:55:14] hays_: so [1,2].length .. wouldn't the receiver be that class instance?
[14:55:38] dminuoso: hays_: the implementation of the method behind it happens to do this.
[14:55:38] dminuoso: hays_: but you could define your own method called `new`
[14:55:38] dminuoso: class Foo; def self.new; puts "Magic!"; end; end
[14:55:39] hays_: and maybe it delegates it to the class itself along with some information about the object?
[14:56:12] dminuoso: hays_: so here is the full and honest truth
[14:56:47] dminuoso: http://i.imgur.com/04Mlrwp.png
[14:57:01] troys: has joined #RubyOnRails
[14:57:44] dminuoso: for method lookup on any receiver, "go one down" (klass), and then follow the chain to the right (super) until you find something that has a method (or method_missing) for the method.
[14:58:04] dminuoso: if found, it will be invoked, while setting `self` to be the receiver inside the method (this is just conceptually)
[14:58:10] dminuoso: if not, NoMethodError will be raised
[14:58:42] hays_: I don't fully understand that, but its interesting. I might need to defer this exploration until later
[14:59:13] dminuoso: Back to your problem :)
[14:59:50] dminuoso: hays_: The RAII/bracket pattern allows you to automatically release resources at the correct time.
[15:00:14] hays_: https://bpaste.net/show/e91b691653f4 here's what we have now
[15:00:58] hays_: to me, I think it doesn't make much sense to call something like establish_connection when creating a new object
[15:01:20] dminuoso: hays_: Needs more context.
[15:01:20] dminuoso: What are you trying to do
[15:01:43] hays_: well I was given this code to use to connect to a database and retrieve some records
[15:02:14] hays_: so I've been given some classes that are derived from ActiveRecord::Base
[15:02:20] dionysus69: I cant access puma.sock
[15:02:24] dionysus69: access denied
[15:02:32] dionysus69: cat gives no such device or address
[15:02:45] dionysus69: and I haven't changed anything, it has to be a puma bug
[15:03:08] dionysus69: so basically, nginx can't access puma socket
[15:03:18] dionysus69: but if I run it as rails s, it can
[15:03:23] hays_: and then there is another class that just defines some passthru methods to these classes and has an initialize method that establishes the connection
[15:03:26] sevenseacat: is puma running?
[15:03:32] dminuoso: dionysus69: You dont get to blame puma for being buggy.
[15:03:43] sevenseacat: its running without a socket?
[15:03:53] dionysus69: ~/.rvm/bin/rvm default do bundle exec puma -C /var/www/user/shared/puma.rb --daemon capistrano or my service starts puma this way, it used to always work
[15:04:05] dminuoso: dionysus69: Your first assumption should be "how did I fuck up". Your second assumption should be "my assumptions are wrong"
[15:04:09] dionysus69: puma.rb is the default config file that is generated by cap puma:config
[15:04:20] sevenseacat: what dminuoso said
[15:04:30] dionysus69: yea but I really didn't change anything, my staging and production both broke
[15:04:53] dionysus69: which makes it even more wierder, now I have production working with rails s until I figure out how did I fuck up :D
[15:04:53] sevenseacat: they just spontaneously both shut down nginx?
[15:05:00] dionysus69: no nginx is fine
[15:05:08] dionysus69: on cap deploy
[15:05:10] sevenseacat: you just said it cant connectto the puma socket
[15:05:20] sevenseacat: is that fine?
[15:05:25] dionysus69: sock file got screwed up but I dont understand how
[15:05:35] sevenseacat: spontaneously?
[15:05:44] fragamus: has joined #RubyOnRails
[15:05:51] dminuoso: sevenseacat: Yes. Radiation from the atmsophere can do that.
[15:05:51] sevenseacat: both servers at the exact same time?
[15:05:58] dionysus69: I guess after I deployed one I didnt expect anything wrong so I deployed the second one too
[15:06:06] dionysus69: which I have done multiple times in past 2 hours
[15:06:08] dminuoso: Happens quite regularly here too. Two servers mysteriously experience the same thing at the same time. It's always radiation.
[15:06:11] sevenseacat: so what changed in the deploy?
[15:06:26] dionysus69: nothing literally
[15:06:33] dionysus69: I reset commit back to where it was
[15:06:33] sevenseacat: then nothing got deployed
[15:06:47] dionysus69: + regenerated vanilla puma.rb at shared path
[15:07:03] dionysus69: the cap command which is used to run puma, obviously stayed same too
[15:07:18] sevenseacat: yeah it sounds like a 'i'm running random things to try and fix something I broke'
[15:07:27] sevenseacat: and without knowing what they are, well
[15:07:41] dionysus69: I was just adding puma workers plugin to Capfile which has nothing to do with all this, plus I reverted that commit and now it is back to just puma plugin
[15:08:08] sevenseacat: adding a puma plugin and now puma doesnt work properly. hmmmmmmm
[15:08:23] sevenseacat: nothing at all to do with it?
[15:08:56] sevenseacat: did you remove the offending plugin?
[15:09:20] dionysus69: it was capistrano plugin not puma plugin though
[15:09:35] dionysus69: Listening on unix:///var/www/user/shared/tmp/sockets/puma.sock
[15:09:42] dionysus69: this is what I get in puma error log
[15:10:22] sevenseacat: how did you install and then uninstall the plugin?
[15:10:45] dionysus69: which should sound fine, but nginx cant access it 201 connect() failed (111: Connection refused) while connecting to upstream, client
[15:10:54] dionysus69: just added to capfile cap staging deploy
[15:11:03] dionysus69: then reverted commit cap staging deploy again
[15:11:18] sevenseacat: did you push the reverted commit?
[15:12:22] sevenseacat: did the reverted commit actually revert all of the changes of adding the plugin?
[15:12:29] dionysus69: I read this for example https://github.com/puma/puma/issues/44
[15:12:43] sevenseacat: did redeploying restart puma with the new configuration?
[15:12:45] dionysus69: did chmod a+rw /tmp/puma.sock, still nothing for me
[15:13:07] dionysus69: yes, even if it didn't I restarted puma manually 100 times since then probably
[15:13:15] dionysus69: I also deleted puma.sock file
[15:13:24] dionysus69: in fact I deleted and recreated whole shared/tmp dir
[15:13:43] dionysus69: restarted nginx couple times too
[15:13:49] dionysus69: that's why I am saying, it's a bug :D
[15:14:07] sevenseacat: very unlikely
[15:14:33] sevenseacat: well, bug in your config maybe
[15:15:44] Technodrome: has joined #RubyOnRails
[15:16:13] dionysus69: it starts with a daemon
[15:16:29] dionysus69: could that be a problem in any way?
[15:16:38] dustinm`: has joined #RubyOnRails
[15:20:52] SteenJobs: has joined #RubyOnRails
[15:34:46] Linuus: has joined #RubyOnRails
[15:39:22] dionysus69: I narrowed it down to puma.rb being corrupt. it works without it :S
[15:39:30] dionysus69: even though it is generated by cap puma:config
[15:41:27] jackhum: has joined #RubyOnRails
[15:47:39] jcarl43: has joined #RubyOnRails
[15:49:59] dionysus69: yep, basically, puma:config generated wrong config file
[15:50:04] dionysus69: it was missing port ENV.fetch("PORT") { 3000 }
[15:55:08] cagomez: has joined #RubyOnRails
[15:58:02] kapil___: has joined #RubyOnRails
[16:01:22] agent_white: has joined #RubyOnRails
[16:08:13] [Butch]: has joined #RubyOnRails
[16:10:52] Linuus: has joined #RubyOnRails
[16:16:00] dblessing: has joined #RubyOnRails
[16:17:24] SteenJobs: has joined #RubyOnRails
[16:22:06] one_zero: has joined #RubyOnRails
[16:22:52] ellcs: has joined #RubyOnRails
[16:27:11] fChanX: has joined #RubyOnRails
[16:30:26] pwnd_nsfw: has joined #RubyOnRails
[16:43:52] fragamus: has joined #RubyOnRails
[16:49:36] orbyt_: has joined #RubyOnRails
[16:51:10] Linuus: has joined #RubyOnRails
[16:55:04] jackhum: has joined #RubyOnRails
[16:56:19] IRCtoo: has joined #RubyOnRails
[16:57:03] guacamole: has joined #RubyOnRails
[16:57:43] jackhum: has joined #RubyOnRails
[16:57:58] guacamole: has anyone sucessfully gotten activeadmin to work with json types in postgres?
[16:59:17] fragamus: has joined #RubyOnRails
[17:01:46] shtirlic: has joined #RubyOnRails
[17:04:34] IRCtoo: I am getting a "SQLite3::SQLException error about "no such table" and lists the table. This table is an OLD table that was renamed in a migration successfully. This causes ALL tests to throw an error (all errors after this one say undefined method 'each' for nil.NilClass. I have db:drop, db:create, db:migrate includin RAILS_ENV=test and still no avail. I have searched within all files
[17:04:34] IRCtoo: for the table name it references and it isn't listed anywhere except for a migration and it was sugbsequently renamed in a migration. I stopped and restarted spring as well as restarted the server. I looked in the SQLite database and there is no reference in any cell to the table listed after the "no such table". The test itself has nothing to do with this said table. I can run the
[17:04:34] IRCtoo: test only on controllers and only have a single test in the controllers test folder and it still throws it. Any suggestions?
[17:06:39] guacamole: IRCtoo restart your computer
[17:07:15] guacamole: a coworker recently had a similar issue and restarting solved it
[17:12:48] dblessing: has joined #RubyOnRails
[17:13:58] kapil___: hello i cannot run this functions: http://www.rubydoc.info/gems/gadget/0.7.0/Gadget#columns-class_method
[17:14:18] FastJack: has joined #RubyOnRails
[17:15:41] kapil___: i given `conn = ActiveRecord::Base.connection`
[17:22:58] fragamus: has joined #RubyOnRails
[17:27:29] kapil___: i got it `conn = PG::Connection.open(:dbname => 'sce_smb_01', :password => 'postgres', :user => 'postgres')`
[17:27:48] IRCtoo: guacamole thank you, but I did already restart the server. :o Is it because that table that was renamed is somehow in cache with springer or something with minitest?
[17:28:15] guacamole: your computer env has something stuck in memory (or something like that)
[17:28:21] guacamole: i'm talking restarting the computer, not the server
[17:28:35] IRCtoo: guacamole - I will try that. Thank you
[17:28:41] guacamole: hope it works!
[17:29:09] Linuus: has joined #RubyOnRails
[17:31:56] dionysus69: has joined #RubyOnRails
[17:32:35] eckhardt: has joined #RubyOnRails
[17:35:19] mroutis: has joined #RubyOnRails
[17:46:10] marr: has joined #RubyOnRails
[17:55:16] mondongo: has joined #RubyOnRails
[17:56:54] Cavallari: has joined #RubyOnRails
[18:01:28] Inside: has joined #RubyOnRails
[18:01:35] Inside: hello #Rails!
[18:01:54] Inside: I have a bunch of roles defined in Active Directory. Does it make sense to use pundit in front of that to perform authorization?
[18:02:03] fl4sh_: has joined #RubyOnRails
[18:02:13] Inside: It'd be an ability-based authorization based on a role-based authentication system
[18:02:50] mroutis: has joined #RubyOnRails
[18:03:03] Linuus: has joined #RubyOnRails
[18:03:03] context: Inside: pundit makes it easy yeah
[18:03:16] Inside: But is it smart(tm)?
[18:03:19] NoGodDamnIdea: has joined #RubyOnRails
[18:03:28] context: Inside: you decide ;)
[18:04:07] Inside: Looks like putting cancan/cancancan in front of LDAP authentication is bad because on every query it goes to check to see if the specific 'can' is enabled
[18:05:18] roshanavand: has joined #RubyOnRails
[18:11:17] Technodrome: has joined #RubyOnRails
[18:12:54] guacamole: is it possible to set up a caching policy for the cans?
[18:16:41] fChanX: has left #RubyOnRails: ()
[18:22:04] sameerynho: has joined #RubyOnRails
[18:27:50] DrYockel: has joined #RubyOnRails
[18:33:07] alfiemax: has joined #RubyOnRails
[18:36:36] woohoou: has joined #RubyOnRails
[18:37:08] alfiemax: has joined #RubyOnRails
[18:37:29] Linuus: has joined #RubyOnRails
[18:46:35] lunarkitty7: has joined #RubyOnRails
[18:48:02] NoGodDamnIdea: has joined #RubyOnRails
[18:51:48] krawchyk: has joined #RubyOnRails
[18:52:19] Linuus: has joined #RubyOnRails
[18:54:13] kapil___: How to add ID column comment in ecto migration?
[19:09:33] Linuus: has joined #RubyOnRails
[19:10:33] SteenJobs: has joined #RubyOnRails
[19:13:35] rikkipitt: has joined #RubyOnRails
[19:14:29] mroutis: has joined #RubyOnRails
[19:18:01] jottr: has joined #RubyOnRails
[19:23:39] jane_booty_doe2: has joined #RubyOnRails
[19:29:38] srinidhi: has joined #RubyOnRails
[19:30:40] mondongo: has joined #RubyOnRails
[19:35:37] kurko_: has joined #RubyOnRails
[19:44:42] mroutis: has joined #RubyOnRails
[19:45:05] alfiemax: has joined #RubyOnRails
[19:48:12] alfiemax_: has joined #RubyOnRails
[19:50:26] eckhardt: has joined #RubyOnRails
[19:55:04] orbyt_: has joined #RubyOnRails
[20:03:29] tdy: has joined #RubyOnRails
[20:14:49] ebsen: has joined #RubyOnRails
[20:17:59] workmad3: has joined #RubyOnRails
[20:21:47] Linuus: has joined #RubyOnRails
[20:26:51] ebsen: has joined #RubyOnRails
[20:33:57] NoGodDamnIdea: has joined #RubyOnRails
[20:41:53] jane_booty_doe: has joined #RubyOnRails
[20:48:43] krawchyk: has joined #RubyOnRails
[20:52:49] krawchyk: has joined #RubyOnRails
[20:55:26] mroutis: has joined #RubyOnRails
[20:56:03] cpruitt: has joined #RubyOnRails
[20:57:39] krawchyk: has joined #RubyOnRails
[21:01:04] Linuus: has joined #RubyOnRails
[21:13:05] fragamus: has joined #RubyOnRails
[21:19:33] NoGodDamnIdea: has joined #RubyOnRails
[21:20:48] rikkipitt: has joined #RubyOnRails
[21:23:48] orbyt_: has joined #RubyOnRails
[21:31:27] jerematic: has joined #RubyOnRails
[21:40:02] Linuus: has joined #RubyOnRails
[21:51:52] _3dwardsharp: has joined #RubyOnRails
[21:51:59] Cache_Money: has joined #RubyOnRails
[21:52:04] rikkipitt: has joined #RubyOnRails
[21:58:23] ur5us: has joined #RubyOnRails
[22:02:46] tekk: has joined #RubyOnRails
[22:07:09] Radar: GOOD MORNING
[22:07:40] alfiemax: has joined #RubyOnRails
[22:15:42] jane_booty_doe: I've done nothing productive today
[22:16:56] Linuus: has joined #RubyOnRails
[22:16:56] workmad3: has joined #RubyOnRails
[22:19:12] ellcs: has joined #RubyOnRails
[22:32:42] GodFather: has joined #RubyOnRails
[22:40:40] Technodrome: has joined #RubyOnRails
[22:41:31] Cache_Money: I craeted a new model (using rails g model ...) and it created the model file but the migration got kinda messed up (I'm assuming) because I tried to rollback and it started to rollback one of my previous migrations. When I run $ rake db:migrate it's trying to create that model file again and it gets hung up. Any tips on how to fix this?
[22:52:44] rikkipitt: has joined #RubyOnRails
[22:58:11] Technodrome: has joined #RubyOnRails
[23:00:26] Linuus: has joined #RubyOnRails
[23:03:44] jottr_: has joined #RubyOnRails
[23:05:13] Radar: Cache_Money: rake db:migrate does not create model files.
[23:05:15] Radar: Cache_Money: !rule0
[23:05:15] helpa: Cache_Money: Show rather than tell. Explaining your problem with code, stacktraces or errors is always preferred to explaining it with just text. Show us what's happening, rather than telling us. Put the code on https://gist.github.com and then give us the HTTP link to the Gist.
[23:14:45] mroutis: has joined #RubyOnRails
[23:15:21] kapil___: has joined #RubyOnRails
[23:18:31] Cache_Money: Radar: Here's the output from the console when I try to run the migration https://gist.github.com/SuperFexy/3601340c137b4202cebb10fe816e677e
[23:18:54] Radar: https://gist.github.com/SuperFexy/3601340c137b4202cebb10fe816e677e#file-console-txt-L13-L16
[23:18:59] Radar: Why are you stopping the process here?
[23:20:14] Cache_Money: Radar: Because I waited 10 minutes and nothing happened. Usually a migration will finish in seconds
[23:20:33] Radar: Cache_Money: Can you show me what that migration does?
[23:21:16] Cache_Money: Radar: I added the migration here: https://gist.github.com/SuperFexy/3601340c137b4202cebb10fe816e677e
[23:21:25] LateralOctober: has joined #RubyOnRails
[23:21:51] Radar: Seems fine.
[23:22:19] Cache_Money: I had another terminal tab open with iPython open that was connected to the same database. I closed the connection and that tab and tried running the migration again but no luck
[23:22:33] Radar: Cache_Money: When you're running that migration, what does `logs/development.log` show? Any queries at all?
[23:24:06] Cache_Money: Radar: I added the end of that log file and included the most recent successful migration https://gist.github.com/SuperFexy/3601340c137b4202cebb10fe816e677e
[23:32:21] Radar: Cache_Money: No idea.
[23:32:25] Radar: Everything seems fine to me.
[23:32:52] darkhanb: has joined #RubyOnRails
[23:34:29] Cache_Money: Radar: I tried to stop my rails server and restart it and I'm getting this: "A server is already running.". Do you think that has something to do with it?
[23:34:41] Radar: Cache_Money: Unknown.
[23:36:50] jottr: has joined #RubyOnRails
[23:37:32] weaksauce: has joined #RubyOnRails
[23:40:36] Linuus: has joined #RubyOnRails
[23:40:40] Cache_Money: Radar: I'm not sure what was happening, so I closed my terminal and opened a new instance. I was able to successfully start a new rails server and then reverted to a previous commit and the new migration worked. ¯\_(ツ)_/¯
[23:40:50] Radar: I blame Spring
[23:40:54] Radar: The gem, not the season.
[23:41:20] kurko__: has joined #RubyOnRails
[23:46:50] samort7: has joined #RubyOnRails
[23:50:52] kurko_: has joined #RubyOnRails
[23:55:53] Avon: has joined #RubyOnRails
[23:58:27] rfoust: has joined #RubyOnRails