« Back to channel list

#RubyOnRails - 08 July 2019

« Back 1 day Forward 1 day »
[00:05:57] brool: has joined #RubyOnRails
[00:11:42] orbyt_: has joined #RubyOnRails
[00:39:11] emptyfl4sk: has joined #RubyOnRails
[01:14:21] s00pcan: has joined #RubyOnRails
[01:27:50] emptyfl4sk: has joined #RubyOnRails
[01:31:11] s00pcan: has joined #RubyOnRails
[01:38:24] tdy: has joined #RubyOnRails
[02:05:36] wmoxam: dgs: QueryCache shouldn't touch memcache, config.action_controller.perform_caching is for stuff like fragment caching
[02:06:15] dgs: any idea where else i should be poking around to try and find why they aren't being cached?
[02:06:52] dgs: or is there another config flag that i should be missing (if perform_caching is for fragment caching etc)
[02:07:12] dgs: s/should be missing/should be looking at/
[02:07:22] wmoxam: it should be enabled by default
[02:07:57] wmoxam: is this app using multiple dbs?
[02:08:10] dgs: hmmm. would be something specific to the database adapter ( we use the oracle_enhanced_adapter which can be sometimes a bit weir)
[02:08:20] dgs: nah, single db per app instance
[02:08:24] wmoxam: could be!
[02:08:39] dgs: k. something else to go look at i guess
[02:10:31] Saukk: has joined #RubyOnRails
[02:11:24] wmoxam: `ActiveRecord::Base.connection.query_cache_enabled` should tell you if its enabled
[02:15:29] dgs: Loading production environment (Rails 4.2.10)
[02:15:29] dgs: 2.4.3 :001 > ActiveRecord::Base.connection.query_cache_enabled
[02:15:30] dgs: => false
[02:15:36] dgs: you are awesome
[02:15:49] dgs: haha. i've been banging my head against this all morning
[02:16:55] dgs: 2.4.3 :006 > ActiveRecord::Base.connection.enable_query_cache!
[02:16:55] dgs: => true
[02:16:55] dgs: 2.4.3 :007 > ActiveRecord::Base.connection.query_cache_enabled
[02:16:57] dgs: => true
[02:17:08] emptyfl4sk: has joined #RubyOnRails
[02:17:13] dgs: right, i'll slap that in the production.rb and see if that works =)
[02:17:16] dgs: cheers man
[02:20:37] srinidhi: has joined #RubyOnRails
[02:31:13] tdy: has joined #RubyOnRails
[02:36:34] dgs: well, that seems to break the database if I add that to production.rb (something i'll need to look at seperately i guess)
[02:36:49] dgs: but, if i enable that in a before filter, it reports itself as being enabled
[02:36:53] dgs: but still no caching
[02:37:08] dgs: is that likely to be something that needs to be configured on app startup?
[02:55:48] emptyfl4sk: has joined #RubyOnRails
[03:06:21] Technodrome: has joined #RubyOnRails
[03:08:58] braincrash: has joined #RubyOnRails
[03:11:48] srinidhi: has joined #RubyOnRails
[03:49:41] tdy: has joined #RubyOnRails
[04:20:32] ariedler: has joined #RubyOnRails
[04:37:54] paulkou: has joined #RubyOnRails
[04:39:11] paulkou: Hello. I have a few different resources that are, depending on polymorphic relationships the child of another resource. I would like to show that parent resource's header on the page. I can see how to do it using partials where the header is rendered explicitly in each view. Is there perhaps a more elegant way to do that using nested layouts or is
[04:39:11] paulkou: that overkill?
[04:40:24] Technodrome: including a partial shouldn't be looked at as repeating yourself
[04:52:26] alxgsv: has joined #RubyOnRails
[05:03:22] quazimodo: has joined #RubyOnRails
[05:03:22] DTZUZO: has joined #RubyOnRails
[05:03:38] za1b1tsu: has joined #RubyOnRails
[05:05:47] emptyfl4sk: has joined #RubyOnRails
[05:13:33] srinidhi: has joined #RubyOnRails
[05:18:03] paulkou: Technodrome: oh that's an interesting take on it!
[05:18:38] paulkou: i think i like that approach more- using nested layouts seems like it's more effort than it's worth anyways. thanks!
[05:18:58] Technodrome: gotta keep your mind on the goal, not obsess
[05:19:19] paulkou: haha got a time machine?
[05:19:31] Technodrome: i went and got a glass of water 3 times in the last 3 hours, i repeated myself, but it was worth it
[05:19:35] Technodrome: same approach i have in rails
[05:19:54] paulkou: it's like i forget that code can be changed after it's written
[05:20:04] Technodrome: if repeating myself feels ok, gets the job done, and i can move on to more important thing, i'm doing it
[05:21:48] paulkou: alright, since we're on a roll: any advice for showing a navbar item as "active"? i'm using shallow nested resources so i can't always rely on the parent resource to give away where I am in the app
[05:22:28] Technodrome: yeah, thats a hole in the ground issue sometmes, it just keeps getting deeper and deeper
[05:22:34] Technodrome: there are some gems for dealing with active menus
[05:22:39] paulkou: I have a navbar with 2 items Foos and Bars. If Baz's can belong to both, and i'm in /bazs/123 is there a simple way?
[05:22:49] paulkou: oh cool i'll see what i can find
[05:23:06] Technodrome: some gems do it by url
[05:23:15] paulkou: wouldn't be a problem at all if i hadn't settled on shallow nested resources
[05:23:29] srinidhi: has joined #RubyOnRails
[05:23:43] conta: has joined #RubyOnRails
[05:25:16] za1b1tsu: has joined #RubyOnRails
[05:25:27] Technodrome: I stay away from shallow nesting
[05:25:44] paulkou: oh really??
[05:26:04] paulkou: i've heard advice to use it from so many people
[05:27:50] paulkou: i guess this is a good reason not to use it
[05:30:33] conta: has joined #RubyOnRails
[05:44:17] conta: has joined #RubyOnRails
[05:48:16] emptyfl4sk: has joined #RubyOnRails
[05:57:32] schne1der: has joined #RubyOnRails
[06:16:35] srinidhi: has joined #RubyOnRails
[06:18:15] Technodrome: paulkou i like to keep things simple
[06:21:13] ariedler: has joined #RubyOnRails
[06:25:37] sandstrom: has joined #RubyOnRails
[06:26:31] paulkou: seems arguable that either is more simple lol
[06:33:57] za1b1tsu: has joined #RubyOnRails
[06:40:47] emptyfl4sk: has joined #RubyOnRails
[07:05:43] conta: has joined #RubyOnRails
[07:08:02] schne1der: has joined #RubyOnRails
[07:16:20] hadifarnoud: has joined #RubyOnRails
[07:19:01] DTZUZO: has joined #RubyOnRails
[07:23:05] emptyfl4sk: has joined #RubyOnRails
[07:28:50] lxsameer: has joined #RubyOnRails
[07:39:07] deepredsky: has joined #RubyOnRails
[07:59:59] ovnimancer: has joined #RubyOnRails
[08:01:29] sandstrom: has joined #RubyOnRails
[08:06:42] emptyfl4sk: has joined #RubyOnRails
[08:08:17] Ergo: has joined #RubyOnRails
[08:14:34] Bounga: has joined #RubyOnRails
[08:17:25] Bounga: Hello, I'm giving a try to ActiveStorage. Seems great. I'm searching for a way to "hook" into file serving process. I'd like to authenticate access to files. So I tried to re-open ActiveStorage::BlobsController but it doesn't work as expected. Does anyone managed to do something like that?
[08:22:03] ariedler: has joined #RubyOnRails
[08:24:35] conta: has joined #RubyOnRails
[08:29:54] ovnimancer: has joined #RubyOnRails
[08:42:10] jefffrails35: has joined #RubyOnRails
[08:47:58] emptyfl4sk: has joined #RubyOnRails
[09:03:54] hadifarnoud: has joined #RubyOnRails
[09:26:38] quazimodo: has joined #RubyOnRails
[09:29:49] emptyfl4sk: has joined #RubyOnRails
[09:54:49] unreal: has joined #RubyOnRails
[10:05:26] emptyfl4sk: has joined #RubyOnRails
[10:11:49] hadifarnoud: has joined #RubyOnRails
[10:24:13] conta: has joined #RubyOnRails
[10:25:59] NL3limin4t0r: Norrin: Are you still wrestling with your ActionController::Parameters problem? `{ "filters" => ["x", "y"] }`
[10:29:15] NL3limin4t0r: Norrin: btw, the reason the RoR guides don't explain what an db index is, is because that is not their responsibility. The build upon the basic understanding of how Ruby, databases and web requests work and therefore only explain how you can achieve things in the framework. They do however need to explain RoR conventions since that's part of what they're providing.
[10:29:36] cassolas: has joined #RubyOnRails
[10:55:08] ariedler: has joined #RubyOnRails
[10:55:12] emptyfl4sk: has joined #RubyOnRails
[10:55:34] armyriad: has joined #RubyOnRails
[11:24:05] cca4: has joined #RubyOnRails
[11:24:25] cca4: Hello, I'm trying to pass my active admin project from 1.3.1 to 1.4.3. I have the following error: Can't be in the context of nil. [, <!DOCTYPE html><html></html> https://dpaste.de/4Ovt#L5 on overrider the head of active admin I have a problem with the function def build_active_admin_head https://github.com/activeadmin/activeadmin/blob/2038da354620
[11:24:25] cca4: 59357f464b294d6695bc5b045ad2/lib/active_admin/views/pages/base.rb#L24
[11:24:31] lankanmon: has joined #RubyOnRails
[11:26:03] hadifarnoud: has joined #RubyOnRails
[11:46:24] emptyfl4sk: has joined #RubyOnRails
[11:51:25] Fretta: has joined #RubyOnRails
[11:54:57] hammer065: has joined #RubyOnRails
[12:02:22] deathwishdave: has joined #RubyOnRails
[12:05:27] conta: has joined #RubyOnRails
[12:21:16] emptyfl4sk: has joined #RubyOnRails
[12:41:43] za1b1tsu: has joined #RubyOnRails
[12:41:46] conta: has joined #RubyOnRails
[13:13:44] frewsxcv: has left #RubyOnRails: ()
[13:34:03] Saukk: has joined #RubyOnRails
[13:53:26] Ropeney: has joined #RubyOnRails
[14:10:26] Sylario: has joined #RubyOnRails
[14:22:16] emptyfl4sk: has joined #RubyOnRails
[14:50:34] sandstrom: has joined #RubyOnRails
[14:52:03] conta: has joined #RubyOnRails
[14:59:15] LtHummus: has joined #RubyOnRails
[15:04:31] algun: has joined #RubyOnRails
[15:04:34] algun: What are the default characteristics of sessions? Is it correct that they are stored client-side (cookies), encrypted, and last forever?
[15:21:12] ascarter: has joined #RubyOnRails
[15:25:27] Dbugger: has joined #RubyOnRails
[15:27:38] ascarter: has joined #RubyOnRails
[15:35:23] Dr_MDMA_MD: has joined #RubyOnRails
[15:35:50] orbyt_: has joined #RubyOnRails
[16:00:31] tdy: has joined #RubyOnRails
[16:02:48] emptyfl4sk: has joined #RubyOnRails
[16:28:38] emptyfl4sk: has joined #RubyOnRails
[16:30:32] NL3limin4t0r: algun: Have a look at the Securing Rails Applications guide. It tells lots about cookies and sessions.
[16:30:39] NL3limin4t0r: algun: https://guides.rubyonrails.org/security.html
[16:33:34] NL3limin4t0r: algun: If that is too much for you. The Action Controller Overview guide covers the basics about sessions.
[16:33:37] NL3limin4t0r: algun: https://guides.rubyonrails.org/action_controller_overview.html#session
[16:34:11] srinidhi: has joined #RubyOnRails
[16:34:23] NL3limin4t0r: ^ might be a better place to start
[16:38:24] schne1der: has joined #RubyOnRails
[16:46:15] conta: has joined #RubyOnRails
[16:51:13] Inside: ugh - a bunch of my tests require that my test database is setup with a certain state
[16:52:41] NL3limin4t0r: 🙋 that's kind of a pain in the ass to do
[16:53:04] Inside: well, I have a number of rake tests that copy data over from production into the test database -_-
[16:54:44] defsdoor: has joined #RubyOnRails
[16:54:59] DTZUZO: has joined #RubyOnRails
[16:59:06] hadifarnoud: has joined #RubyOnRails
[17:02:24] deepredsky: has joined #RubyOnRails
[17:10:51] deepreds1: has joined #RubyOnRails
[17:19:29] kurko_: has joined #RubyOnRails
[17:20:58] Norrin: NL3limin4t0r thanks for getting back to me
[17:21:18] Norrin: i'm wrestling with macro/method definitions a bit on activerecord
[17:21:50] Norrin: tabledefintion.references for example doesn't seem to mention the class_name: option
[17:21:55] Norrin: for example
[17:24:18] hadifarnoud: has joined #RubyOnRails
[17:27:43] brool: has joined #RubyOnRails
[17:28:58] uksio: has joined #RubyOnRails
[17:42:11] crankharder: has joined #RubyOnRails
[17:46:15] DTZUZO: has joined #RubyOnRails
[17:59:40] NL3limin4t0r: Inside: I feel your frustration. I've added tens of tests just before the weekend, but still have a lot of tests to write (we've quite a backlog). When everything works it's kinda calming until you hit some strange scenario that doesn't lend itself well for testing.
[18:02:54] NL3limin4t0r: Norrin: You mean like `t.references :post`? Where t is the comments database. But you'd like to specify a different table than the posts table, but still keep the column names the same?
[18:04:36] Norrin: NL3limin4t0r like a self join table
[18:04:50] Norrin: a model that can reference itself
[18:10:03] DTZUZO: has joined #RubyOnRails
[18:10:21] NL3limin4t0r: Norrin: `t.references :parent, index: true, foreign_key: { to_table: :people }` where t is the people table.
[18:12:14] algun: NL3limin4t0r, that's where I started, but it doesn't say anything about expiry default
[18:12:40] deepredsky: has joined #RubyOnRails
[18:12:47] algun: The more detailed article implies that by default it's limitless
[18:13:59] algun: Also it's a bit confusing that it says "However the client can edit cookies that are stored in the web browser so expiring sessions on the server is safer.", when the Cookie Store encrypts them.
[18:14:25] algun: I guess I'll assume my assumptions are correct
[18:14:34] NL3limin4t0r: What do you mean with "expiry default"?
[18:14:52] NL3limin4t0r: algun: Oh, you mean the cookies.
[18:14:56] algun: the default lifetime of a session
[18:15:37] NL3limin4t0r: That's what you get from talking with too many people at once. I thought this was about the database columns. xD
[18:16:58] algun: NL3limin4t0r, I appreciate you trying to help and excuse my crankiness
[18:18:23] algun: I'm trying to find out if there are session solutions that don't use refresh and access tokens but protect against hijacking
[18:18:39] algun: Sane solutions
[18:24:06] NL3limin4t0r: algun: here is how you can set the cookie expiry https://stackoverflow.com/q/1232174/3982562 and this SO question asks about the default https://stackoverflow.com/q/10645083/3982562
[18:48:49] conta: has joined #RubyOnRails
[18:54:13] tfreedman: has left #RubyOnRails: ("User left")
[19:08:50] deepreds1: has joined #RubyOnRails
[19:19:40] Exuma: has joined #RubyOnRails
[19:21:21] emptyfl4sk: has joined #RubyOnRails
[19:30:09] FLeiXiuS: has joined #RubyOnRails
[19:30:33] ellcs: has joined #RubyOnRails
[19:31:12] FLeiXiuS: I have a has_many through, with a field called 'type'. I'm defining checkboxes using collection_check_boxes. Is there a way to define the `type` for the associated checkbox?
[19:39:51] emptyfl4sk: has joined #RubyOnRails
[20:25:48] ellcs: has joined #RubyOnRails
[20:41:16] Exuma: has joined #RubyOnRails
[21:12:23] Exuma: has joined #RubyOnRails
[21:16:52] deepredsky: has joined #RubyOnRails
[21:50:43] Exuma: has joined #RubyOnRails
[21:51:56] mlt-: Can I split a text within a variable into 5 lines + rest? I know #lines, but it splits everything
[21:56:54] havenwood: mlt-: Sure! Show us an example of what you have, and what you want, if you'd like code suggestions.
[22:00:30] mlt-: havenwood: I want rest of text in a single element http://rubyfiddle.com/riddles/0a9e1
[22:00:44] mlt-: without joining back what was split
[22:00:54] DTZUZO: has joined #RubyOnRails
[22:12:34] havenwood: mlt-: You could use Regexp or StringScanner.
[22:13:32] mlt-: That is what I'm trying out...if I could use look-behind and count up to 3 newlines to split or something'
[22:13:41] havenwood: mlt-: line = /(.*\n)/; rest = /(.*\Z)/; pattern = /#{line}#{line}#{line}#{line}#{rest}/o; txt.match(pattern).captures
[22:13:48] havenwood: mlt-: ^ that's one option of many
[22:24:08] havenwood: mlt-: Another option: txt.partition(/(?:.*\n){,5}/).then { |_, before, after| before.lines << after }
[22:24:23] mlt-: then is 2.6 thing?
[22:24:34] mlt-: I'm on 2.4 for now
[22:24:36] havenwood: mlt-: Yeah, or you could use #yield_self alias in 2.5.
[22:25:17] havenwood: mlt-: In 2.4 you could: _, before, after = txt.partition /(?:.*\n){,5}/; [*before.lines, after]
[22:25:58] havenwood: mlt-: That's ^ a little too ugly, so I'd probably do another solution.
[22:26:35] havenwood: mlt-: Also, there are edgecases around less than 5 total matches, which you could handle various ways depending on your requirements.
[22:26:49] mlt-: it is fixed number of lines
[22:26:52] mlt-: in the header
[22:27:35] mlt-: apparently can't fiddle with #partition... as web thing is 1.9.3 )
[22:27:49] havenwood: mlt-: There are simpler solutions, sec.
[22:28:16] havenwood: mlt-: lines = txt.lines; [*lines.first(5), lines.drop(5).join]
[22:30:08] ajamielittle: has joined #RubyOnRails
[22:30:18] mlt-: I like #partition. I can do #lines on the first part. I do not want to join result of complete #lines. I thought to reduce memory impact... but I guess who cares)
[22:39:22] Exuma: has joined #RubyOnRails
[22:39:39] mlt-: Thank you for spending time! I think since there is no very simple solution that would not complicate things, I am happy keeping #lines that I already use
[22:53:21] Dbugger: has joined #RubyOnRails
[23:06:15] emptyfl4sk: has joined #RubyOnRails
[23:19:32] mlt-: Now I wonder if there is a uniform way to open local files and http urls (to download whole file). I'm not sure Net::HTTP I was using can handle file:// . I see open-uri , but RuboCop complains on #open
[23:31:40] havenwood: mlt-: Are you parsing user content to get file paths?
[23:32:34] havenwood: mlt-: I mean, are these user-supplied paths?
[23:32:52] havenwood: mlt-: You can ignore RuboCop when you feel like breaking the rubolaw.
[23:32:54] orbyt_: has joined #RubyOnRails
[23:33:14] mlt-: it is either web service or test case with file fixture
[23:33:41] mlt-: I am contemplating on extending URI with file scheme and using URI#open
[23:34:13] havenwood: mlt-: The reason RuboCop is objecting to Kernel#open is that you can invoke a command with it.
[23:34:23] mlt-: yeah, I understand that
[23:34:39] havenwood: So ignore RuboCop :)
[23:34:48] mlt-: It is just undermines all awesomeness of open-uri
[23:34:56] mlt-: yeah, I might ignore that particular one
[23:35:22] havenwood: mlt-: The reason for the cop is to catch cases where you really mean to File.open, which is actually common.
[23:35:23] mlt-: I mean awesomeness of uniformity for file:// and http://
[23:35:46] mlt-: I would need to figure out how to make an exception for a single file )
[23:36:32] mlt-: let me mess with extending thing firat
[23:37:00] havenwood: mlt-: Something like: Security/Open: Excludes: -path/to/file.rb
[23:37:22] havenwood: but YAML and Exclude:
[23:41:01] quazimodo: has joined #RubyOnRails
[23:41:10] mlt-: nice.. both ways work... monkey-patching and exclude:
[23:41:58] mlt-: I read somewhere that it is better not to monkey-patch (reopen?) the actual class, but to #send(:include, mymodule)
[23:44:03] havenwood: mlt-: There's no harm I can think of in just opening the class to include a module.
[23:44:39] havenwood: mlt-: It's nicer to include a module to show where your patch came from.
[23:45:02] havenwood: mlt-: Alternatively, these days you can use refinements to lexically scope the patch - which is better yet.
[23:45:40] mlt-: So... here is the aproach with monkey patching https://stackoverflow.com/a/28731336/673826 ... and here is what I had in mind
[23:45:53] havenwood: mlt-: It's nicer to leave a module trail for the global monkey patching you're doing. It's nicer yet to not globally monkey patch and refine instead.
[23:48:26] mlt-: What exactly do you mean by "refine"? Quite often I see things like https://github.com/metaminded/tabulatr2/blob/master/lib/tabulatr/data/dsl.rb#L144 (ignore irrelevant project...just example of #send :extend/:include)
[23:49:05] mlt-: but...what confuses me is @@schemes
[23:49:05] havenwood: mlt-: For your case, you'd probably be prepending, not including, right?
[23:49:14] havenwood: mlt-: Refinements are something a bit different: https://docs.ruby-lang.org/en/2.4.0/syntax/refinements_rdoc.html
[23:49:41] havenwood: mlt-: Meant to link: https://docs.ruby-lang.org/en/2.6.0/syntax/refinements_rdoc.html
[23:50:15] mlt-: 2.4 is quite relevant :-) I never used refine before... I see the point
[23:51:44] mlt-: let me try
[23:54:10] mlt-: Same problem... uninitialized class variable @@schemes in MyURI
[23:54:27] mlt-: so I can't refine class variables?
[23:54:58] havenwood: mlt-: That class variable (yuck) is at the URI module level, not at the URI::File class level.
[23:55:38] mlt-: I thought I can refine module? Classes only? :-)
[23:56:27] mlt-: There is no URI::File in ruby 2.4 AFAIK
[23:56:55] mlt-: I see 2.6 is better in that regard https://ruby-doc.org/stdlib-2.6.1/libdoc/uri/rdoc/URI/File.html