« Back to channel list

#RubyOnRails - 16 May 2019

« Back 1 day Forward 1 day »
[00:02:48] Psy-Q: has joined #RubyOnRails
[00:13:50] tdy1: has joined #RubyOnRails
[00:14:41] orbyt_: has joined #RubyOnRails
[00:24:33] octos: has joined #RubyOnRails
[00:29:51] Haydos: has joined #RubyOnRails
[00:44:37] jottr: has joined #RubyOnRails
[00:44:48] Technodrome: has joined #RubyOnRails
[01:26:16] jottr: has joined #RubyOnRails
[01:30:45] gambl0re: has joined #RubyOnRails
[01:34:10] orbyt_: has joined #RubyOnRails
[01:54:09] bga57: has joined #RubyOnRails
[02:01:45] jottr: has joined #RubyOnRails
[02:11:48] Technodrome: weird question, but after all these years of using rails, it still feels like i'm using some DSL, anyone else have this feeling?
[02:25:32] cnsvc_: has joined #RubyOnRails
[02:33:10] Saukk: has joined #RubyOnRails
[02:36:27] pd09041999: has joined #RubyOnRails
[02:37:18] bamdads: has joined #RubyOnRails
[02:49:56] gambl0re: has joined #RubyOnRails
[02:57:35] regedit: has joined #RubyOnRails
[03:11:38] braincrash: has joined #RubyOnRails
[03:12:08] duderonomy: has joined #RubyOnRails
[03:13:35] tdy: has joined #RubyOnRails
[04:04:38] altigraph: has joined #RubyOnRails
[04:13:34] jottr: has joined #RubyOnRails
[04:20:35] orbyt_: has joined #RubyOnRails
[04:23:54] srinidhi: has joined #RubyOnRails
[04:24:42] Rustputin: has joined #RubyOnRails
[04:35:26] duderonomy: has joined #RubyOnRails
[04:36:39] havenwood: Technodrome: I just feel like I'm putting code in drawers. A bunch of tiny, carefully labeled drawers.
[04:44:05] arathald: has joined #RubyOnRails
[05:02:11] cnsvc_: has joined #RubyOnRails
[05:08:02] morozovm: has joined #RubyOnRails
[05:24:16] conta: has joined #RubyOnRails
[05:40:42] morozovm: has joined #RubyOnRails
[05:55:08] sevenseacat: has joined #RubyOnRails
[06:16:21] pd09041999: has joined #RubyOnRails
[06:19:17] prestorium: has joined #RubyOnRails
[06:20:13] jottr: has joined #RubyOnRails
[06:27:30] Technodrome: has joined #RubyOnRails
[06:30:51] lypsis: has joined #RubyOnRails
[06:40:41] hive-mind: has joined #RubyOnRails
[07:13:14] davidh38: has joined #RubyOnRails
[07:16:18] uksio: has joined #RubyOnRails
[07:20:39] davidh38: has joined #RubyOnRails
[07:26:59] lxsameer: has joined #RubyOnRails
[07:27:04] cnsvc_: has joined #RubyOnRails
[07:47:48] xco: has joined #RubyOnRails
[07:56:33] davidh38: has joined #RubyOnRails
[07:58:48] davidh38: has joined #RubyOnRails
[07:59:11] Ergo: has joined #RubyOnRails
[08:03:58] davidh38: has joined #RubyOnRails
[08:14:41] ChrisBr: has joined #RubyOnRails
[08:21:11] jottr: has joined #RubyOnRails
[08:29:23] jefffrails35: has joined #RubyOnRails
[08:36:06] davidh38: has joined #RubyOnRails
[08:42:15] davidh38: has joined #RubyOnRails
[08:43:59] davidh38: has joined #RubyOnRails
[08:59:17] tbuehlmann: has joined #RubyOnRails
[09:05:28] cnsvc_: has joined #RubyOnRails
[09:14:07] cnsvc_: has joined #RubyOnRails
[09:15:54] davidh38: has joined #RubyOnRails
[09:50:53] xco: has left #RubyOnRails: ()
[09:52:36] apparition: has joined #RubyOnRails
[10:18:25] conta: has joined #RubyOnRails
[10:54:57] lankanmon: has joined #RubyOnRails
[10:59:06] davidh38: has joined #RubyOnRails
[11:17:47] tf2ftw: has joined #RubyOnRails
[11:18:23] gb_away: has joined #RubyOnRails
[11:20:53] davidh38: has joined #RubyOnRails
[11:36:55] dionysus69: has joined #RubyOnRails
[11:40:21] GodFather: has joined #RubyOnRails
[11:45:05] GodFather_: has joined #RubyOnRails
[11:47:47] Technodrome: has joined #RubyOnRails
[11:49:18] Technodrome: havenwood interesting you said that, sorta how I feel
[11:49:34] Technodrome: reminds me of smalltalk so much, people used to build apps and literally had no clue how the system worked at all
[11:53:44] dslegends: has joined #RubyOnRails
[11:57:02] apparition: has joined #RubyOnRails
[12:04:00] Dbugger: has joined #RubyOnRails
[12:24:37] lato: has joined #RubyOnRails
[12:24:46] apparition: has joined #RubyOnRails
[12:24:55] uksio: has joined #RubyOnRails
[12:52:21] jottr: has joined #RubyOnRails
[12:56:08] cnsvc_: has joined #RubyOnRails
[12:58:56] prestorium: has joined #RubyOnRails
[12:59:51] haxx0r: has joined #RubyOnRails
[13:06:09] conta2: has joined #RubyOnRails
[13:11:01] Dbugger: has joined #RubyOnRails
[13:21:23] ovnimancer: has joined #RubyOnRails
[13:25:11] tf2ftw: has joined #RubyOnRails
[13:30:18] jottr: has joined #RubyOnRails
[13:46:38] jefffrails35: has joined #RubyOnRails
[14:13:47] zacts: has joined #RubyOnRails
[14:17:05] dviola: has joined #RubyOnRails
[14:25:41] GodFather: has joined #RubyOnRails
[14:26:03] GodFather_: has joined #RubyOnRails
[14:59:21] duderonomy: has joined #RubyOnRails
[15:16:12] gambl0re: has joined #RubyOnRails
[15:17:07] pd09041999: has joined #RubyOnRails
[15:18:38] orbyt_: has joined #RubyOnRails
[15:18:49] pd09041999: has joined #RubyOnRails
[15:38:19] eddof13: has joined #RubyOnRails
[15:40:39] davidh38: has joined #RubyOnRails
[15:44:39] davidh38: has joined #RubyOnRails
[15:47:36] tf2ftw: Is the Rails tmp folder automatically pruned?
[15:49:17] tf2ftw: Looks like it's not. Probably best to use Tempfile
[15:51:39] davidh38: has joined #RubyOnRails
[15:55:29] choke: has joined #RubyOnRails
[15:55:52] davidh38: has joined #RubyOnRails
[16:14:24] davidh38: has joined #RubyOnRails
[16:15:29] broman: has joined #RubyOnRails
[16:15:48] agent_white: has joined #RubyOnRails
[16:16:04] broman: can someone please help me? I need to make a socket (ok) and make it persistent (one for each connection)... does anybody knows any way to accomplish that?
[16:16:50] davidh38: has joined #RubyOnRails
[16:17:02] regedit: has joined #RubyOnRails
[16:18:43] tdy: has joined #RubyOnRails
[16:26:03] zacts: has joined #RubyOnRails
[16:31:54] choke: has joined #RubyOnRails
[16:33:41] gambl0re: has joined #RubyOnRails
[16:42:19] Momentum: broman: how is that relevant in a rails channel?
[16:46:40] lupine: perhaps it's a rails application listening on a socket
[16:49:06] broman: Momentum, I'm using ruby on rails
[16:50:14] Momentum: that's still not relavant to rails, i can use machine learning inside a rails app so i ask about ML here?
[16:53:04] Momentum: you can ask on #ruby or check out this https://docs.ruby-lang.org/en/2.1.0/Socket.html
[17:00:59] KeyJoo: has joined #RubyOnRails
[17:19:52] cnsvc_: has joined #RubyOnRails
[17:31:05] IGnorAND: What does one need to do to not write FactoryBot.build in my spec, but write build? I thought the rails_helper should've 'solved' that
[17:36:09] MrCrackPotBuilde: has joined #RubyOnRails
[17:40:35] Dbugger: has joined #RubyOnRails
[17:44:52] Dbugger: Hi everyone
[17:45:14] Dbugger: Could someone please take a look at my code, and tell me if there is a smarter way to do this?
[17:45:17] Dbugger: https://codereview.stackexchange.com/questions/220298/ruby-on-rails-creating-many-models-associated-with-another-one
[17:45:24] broman: Momentum, I'm sorry, I meant in the context of rails, I need to open a ruby socket for each rails connection... sure, you can do a lot of things on top of other things, but my main concern here is to instantiate a socket connection and make it persistent for each rails connection
[18:00:47] tf2ftw: has joined #RubyOnRails
[18:08:25] tdy: has joined #RubyOnRails
[18:10:23] HumorBaby: has joined #RubyOnRails
[18:14:13] HumorBaby: I am using rails 5.0.1 ActionMailer with delayed_job and mjml-rails. Is it possible to delay sending mail after the mailer has already been rendered?
[18:15:00] HumorBaby: mjml-rails is a real bottle neck (relative to no mjml)
[18:16:21] HumorBaby: My goal is to send hundreds of emails ~at once. having mjml re-render each mail can take up to ~1 second, and so this means that with mjml, the first and last email sent could be ~5-10 minutes apart by the time they pass through the downstream mail server
[18:16:53] HumorBaby: i was hoping to render the email before the job is queued, and schedule the job to run ~15 minutes from_now, so that there is no rendering lag
[18:17:50] zacts: has joined #RubyOnRails
[18:38:43] jottr: has joined #RubyOnRails
[18:39:28] jefffrails35: has joined #RubyOnRails
[18:49:58] planigan: has joined #RubyOnRails
[18:58:35] zacts: has joined #RubyOnRails
[18:58:38] octos: has joined #RubyOnRails
[19:00:25] IGnorAND: I have a class with a lot of attributes. Is there a way to shorten my initializer. I do @account_key = opts[:account_key] for every attribute (where account_key is the first of many attributes)
[19:02:44] tf2ftw: has joined #RubyOnRails
[19:05:38] tf2ftw: has joined #RubyOnRails
[19:06:59] tdy: has joined #RubyOnRails
[19:11:48] davidh38: has joined #RubyOnRails
[19:11:55] cnsvc_: has joined #RubyOnRails
[19:26:19] benlieb: has joined #RubyOnRails
[19:27:42] tf2ftw: has joined #RubyOnRails
[19:28:59] ovnimancer: has joined #RubyOnRails
[19:31:24] davidh38: has joined #RubyOnRails
[19:31:32] jottr: has joined #RubyOnRails
[19:33:11] cnsvc_: has joined #RubyOnRails
[19:43:45] xco: has joined #RubyOnRails
[19:44:04] xco: Hi! How do you interpolate strings in something like this?
[19:44:05] xco: ActiveRecord::Base.connection.execute("select * from addresses where lower(city) ilike 'rome'").values
[19:44:21] xco: i want to make city = “rome”
[19:44:43] xco: but when i interpolated using #{city} PG doesn’t seem to like it
[19:44:49] xco: i’m sure it’s because of the double quotes
[19:45:38] xco: i get this error
[19:45:39] xco: ActiveRecord::StatementInvalid (PG::SyntaxError: ERROR: syntax error at or near "{")
[19:45:40] xco: LINE 1: select * from addresses where lower(city) ilike #{cty}
[19:47:55] eddof13: has joined #RubyOnRails
[19:48:17] ravenous_: has joined #RubyOnRails
[19:49:33] jottr: has joined #RubyOnRails
[19:52:18] davidh38: has joined #RubyOnRails
[19:53:00] ravenousmoose: has joined #RubyOnRails
[19:59:10] havenwood: xco: ILIKE is case insensitive, so no need to also lower()
[19:59:30] xco: yeah i removed it long ago :)
[19:59:33] xco: but thanks
[20:00:07] havenwood: %{SELECT * FROM %{from} WHERE ILIKE "%{city}"} % {from: 'addresses', city: 'rome'}
[20:00:27] havenwood: #=> "SELECT * FROM addresses WHERE ILIKE \"rome\""
[20:00:53] xco: this worked too
[20:00:53] xco: ActiveRecord::Base.connection.execute("select * from addresses where city ilike '#{cty}'").values
[20:01:01] havenwood: xco: If you're using Postgres you might consider using CITEXT
[20:01:13] xco: ‘#{cty}’
[20:02:27] havenwood: A nice thing about CITEXT is you get indexes without having to backbend with a function index using lower.
[20:02:59] havenwood: xco: Also, you can then just use the regular Rails query.
[20:03:12] xco: i have multiple fields that i need to perform an AND operator on in the db. i’m using params to pass the values from these fields. what would be the best way to get do this considering a user might fill some fields and leave others? yet i want to do AND on all the fields that are not empty?
[20:03:19] havenwood: Rails supports CITEXT nicely
[20:03:33] xco: havenwood: thanks :)
[20:03:40] havenwood: https://mikecoutermarsh.com/storing-email-in-postgres-rails-use-citext/
[20:03:41] xco: i’ll look into it
[20:03:47] havenwood: https://nandovieira.com/using-insensitive-case-columns-in-postgresql-with-citext
[20:04:04] havenwood: Indexes ftw.
[20:04:11] havenwood: So. Much. Faster.
[20:04:39] xco: havenwood: what do you mean by indexes? are you referring to my question about multified search with AND?
[20:06:31] havenwood: xco: When you're doing WHEREs and such, indexes massively speed up DB performance. It's important to add indexes for fields you're going to query by. With CITEXT, you get indexes for the case insensitive fields.
[20:06:58] havenwood: It *just works* like a regular index, no need to fiddle with lower() functions for your index.
[20:07:08] havenwood: https://semaphoreci.com/blog/2017/05/09/faster-rails-is-your-database-properly-indexed.html
[20:07:19] havenwood: http://www.rakeroutes.com/blog/increase-rails-performance-with-database-indexes/
[20:07:26] havenwood: https://karolgalanciak.com/blog/2018/08/19/indexes-on-rails-how-to-make-the-most-of-your-postgres-database/
[20:07:47] xco: havenwood: i think that’s not the answer to my question :P
[20:07:54] xco: unless it’s for some other person
[20:08:25] havenwood: xco: I'm just saying that using CITEXT for your case insensitive fields gives you free indexing.
[20:08:36] havenwood: You do have to add the index, but it *just works* with case insensitive fields.
[20:08:38] xco: aaaaah yes i got that! :D
[20:08:56] xco: i asked a second question though
[20:09:02] xco: i’ll repaste it if you can help
[20:09:10] xco: Also, you can then just use the regular Rails query.
[20:09:10] xco: [10:03pm] xco: i have multiple fields that i need to perform an AND operator on in the db. i’m using params to pass the values from these fields. what would be the best way to get do this considering a user might fill some fields and leave others? yet i want to do AND on all the fields that are not empty?
[20:09:25] xco: this is what i have started with https://gist.github.com/xcobar/9a00e350b71bce66d4f9efe68c32882f
[20:09:41] havenwood: Ah, didn't see that question.
[20:09:58] xco: on line 11 for instance i don’t want to perform an AND there if that param is empty, it wouldn’t make sense
[20:10:19] xco: so i need a way to sort of dynamically do the AND on fields that are present
[20:21:10] tdy: has joined #RubyOnRails
[20:22:30] cek: has joined #RubyOnRails
[20:24:47] duderonomy: has joined #RubyOnRails
[20:24:52] havenwood: xco: I replied to your gist.
[20:25:33] havenwood: xco: There are many ways. I didn't look beyond dynamically generating the query for options. (Multitasking.)
[20:30:38] cek: has left #RubyOnRails: ()
[20:32:24] xco: havenwood: thanks! need some minutes to digest this one :D
[20:32:53] xco: %i[= line1] making it a symbol?
[20:33:27] havenwood: xco: Yes, that's an Array of two Symbols.
[20:33:36] havenwood: xco: You could also use %w for strings.
[20:33:38] havenwood: xco: [:"=", :line1]
[20:33:44] havenwood: xco: Sec, I'll make this simpler.
[20:35:13] xco: actually i get it
[20:35:19] xco: but never would have thought of it this way
[20:35:29] xco: this is smart
[20:38:15] jefffrails35: has joined #RubyOnRails
[20:38:27] havenwood: xco: Posted another comment, with a slightly flattened version around #reduce.
[20:38:58] xco: perfect
[20:39:09] xco: so here “next” will only take values that are not nil
[20:39:14] prestorium: has joined #RubyOnRails
[20:39:34] havenwood: xco: `next sql` passes the `sql` string onto the next reduction
[20:39:56] tf2ftw: has joined #RubyOnRails
[20:40:05] havenwood: xco: or on the following line, it'll pass `sql + AND...` to the next reduction
[20:40:10] xco: yes, and it’ll only do it if the value of public_send(meth) is NOT nil? right?
[20:40:27] havenwood: xco: not nil or false
[20:40:53] xco: let me try this out! :)
[20:41:15] zacts: has joined #RubyOnRails
[20:44:54] benlieb: has joined #RubyOnRails
[20:51:33] xco: havenwood: mind reviewing this for me please https://gist.github.com/xcobar/9a00e350b71bce66d4f9efe68c32882f
[20:51:58] havenwood: xco: Put the constant outside the method.
[20:52:11] xco: and also it looks like i’ll need to enable an extension to use citext
[20:52:27] havenwood: xco: The constant only needs to be defined once. You should also probably freeze it, for good measure.
[20:52:28] havenwood: xco: Yes, you can enable the extension in a migration. It's a one-liner.
[20:52:57] xco: Rubocop will do the freezing :P
[20:53:12] havenwood: xco: You can ditch lines 12-15 now.
[20:53:21] havenwood: oh, you're using cty
[20:53:33] xco: first time hearing about this citext thing, pretty excited i learned that from you! will make a blog post for my future self about this
[20:53:44] havenwood: xco: ditch lines 12-13 & 14
[20:54:20] xco: ah right
[20:54:25] xco: looks good now i guess
[20:54:36] havenwood: xco: Awesome! Another neat thing to remember is that Postgres supports Trigrams with indexes, which work great with Rails: https://www.postgresql.org/docs/current/pgtrgm.html
[20:54:58] havenwood: xco: That lets you accommodate typos, etc, and still find the nearest matches.
[20:55:08] havenwood: xco: And... it's indexable with Rails!
[20:55:33] xco: perhaps i’ll need to enable more extenstions for this?
[20:55:36] havenwood: https://scoutapm.com/blog/how-to-make-text-searches-in-postgresql-faster-with-trigram-similarity
[20:55:49] havenwood: xco: Yes, this is the pg_trgm extension.
[20:56:04] xco: this is cool!!
[20:56:27] havenwood: xco: But, these are typically available with Postgres - they're the common extensions. You can use them on Heroku, etc, just out of the box after enabling them with a oneliner in a migration.
[20:56:56] havenwood: https://scoutapm.com/blog/pg_trgm-autocorrect
[21:03:12] xco: awesome!
[21:17:29] truenito: has joined #RubyOnRails
[21:22:30] jottr: has joined #RubyOnRails
[21:34:13] ur5us: has joined #RubyOnRails
[21:36:16] jottr: has joined #RubyOnRails
[21:46:44] eddof13: has joined #RubyOnRails
[21:48:10] weteamsteve: has joined #RubyOnRails
[21:55:15] mcr: has joined #RubyOnRails
[22:08:39] davidh38: has joined #RubyOnRails
[22:10:43] amperry: has joined #RubyOnRails
[22:11:53] amperry: hey folks, I've got a scope for a model, Unit.non_revs, which, to_sql, becomes "SELECT `units`.* FROM `units` WHERE `units`.`non_revenue_status_id` IS NOT NULL AND `units`.`null_unit` IS NULL".
[22:13:03] amperry: In the console, I've looked for one unit, u, which I *know* has a non-null 'non_revenue_status_id', and a null 'null_unit'; but Unit.non_revs gives me empty brackets.
[22:14:28] amperry: I don't even know how to troubleshoot this from here.
[22:16:01] lupine: basic sanity check: see if it shows up when find it by id, and then by the two args directly
[22:16:08] lupine: when you find it by*
[22:17:11] amperry: lupine: find_by_id works; when you say by the two args directly, you mean something like Unit.where.not(non_revenue_status_id: nil) ?
[22:17:32] amperry: because u.non_revenue_status_id = 6, which is a valid value, and u.null_unit is nil
[22:19:40] lupine: so `Unit.where(non_revenue_status_id: 6, null_unit: nil)
[22:20:27] amperry: yeah; it might be that I've changed something in the console and haven't saved it, derp.
[22:20:48] amperry: yup, just me being fuzzy-headed
[22:21:03] amperry: lupine: but thanks anyhow
[22:23:28] jottr: has joined #RubyOnRails
[22:51:06] ramfjord: has joined #RubyOnRails
[23:12:38] eddof13: has joined #RubyOnRails
[23:15:21] gambl0re: has joined #RubyOnRails
[23:21:03] beingjohnm: has joined #RubyOnRails
[23:24:39] uks: has joined #RubyOnRails
[23:45:53] IGnorAND: I made my first ever gem, my tests work, but when I add it to another app, I get missing gem which is in my gemspec
[23:46:53] brool: has joined #RubyOnRails
[23:53:05] IGnorAND: Looks like this, but am missing an external dep https://stackoverflow.com/questions/27790712/making-a-ruby-gem-cannot-load-such-file
[23:59:41] orbyt_: has joined #RubyOnRails