#RubyOnRails - 25 April 2018
« Back 1 day Forward 1 day »
[03:04:39] baweaver: Proper pattern matching is currently being discussed on the Ruby bug tracker: https://bugs.ruby-lang.org/issues/14709
[05:42:17] JJonah: I have a file `lib/authentication/strategy.rb` containing the class `Authentication::Strategy` and I in application.rb I have `config.autoload_paths << Rails.root.join('lib')`. I am getting the error `Authentication is not a module` from a controller using the `Authentication::Strategy` class. I thought autoloading should make it available. What am I missing?
[05:51:55] JJonah: adding require statements to the top of controller fixes the problem. is this intended? or should i not need the explicit requires?
[07:13:02] tbuehlmann: JJonah: do you have any other classes/modules named Authentication? also, can you gist a minimal reproduction?
[08:16:23] dionysus69: what's the best practice for retrieving single record without writing Model.find_by(attr: :asd).some_method
[08:17:15] dionysus69: what if I want to do that multiple times on single page, just takes lots of space visually
[08:19:50] dionysus69: one option is to declare a variable and then use that, that would save space but would add extra line xD
[08:32:20] sevenseacat: I think we need more context about the problem to be able to offer more advice
[09:02:16] dminuoso: 10:19 dionysus69 | one option is to declare a variable and then use that, that would save space but would add extra line xD
[09:02:38] dminuoso: You are a software developer, you are looking for an abstraction - but adding extra lines is scary?
[09:14:57] helpa: dionysus69: 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.
[09:16:11] dminuoso: Radar: so webpacker is preconfigured with an uglifier that incorrectly produces es6 unicode code point escape sequences in string literals.
[09:18:14] dminuoso: Radar: Long story short: webpacker needs to do whatever version upgrades to include this: https://github.com/mishoo/UglifyJS2/pull/2246/files
[09:19:22] Radar: There's at least _a_ version out with the patch included in it judging by https://github.com/mishoo/UglifyJS2/commit/6a5e74b44e65811b2152f72aeec8df3f75457663
[09:21:14] Radar: https://github.com/webpack-contrib/uglifyjs-webpack-plugin/blob/master/package.json#L39 <- would probably need to bump this
[09:23:25] Radar: dminuoso: At least, I think that's the spot. I think rails/webpacker uses uglifyjs-webpack-plugin in webpacker's package.json. Bumping the version in uglifyjs-webpack-plugin, would then mean that webpacker would also need a version bump... but then the whole chain of packages should then include the right uglifier version which will _probably_ fix your issue.
[09:28:07] Radar: In other news, I have a new book out: https://leanpub.com/explodingrails. TL;DR is: Death to Active Record. Long live ROM!
[09:29:34] Radar: I also gave a talk about this same topic at Melbourne RoRo recently. The video should be out for that soon-ish, but the slides are here: https://speakerdeck.com/radar/exploding-rails
[09:34:47] dang`r`us: dminuoso, the project I'm building replaces one without an ORM ... it's quite the sight
[09:35:06] dang`r`us: lots of core logic in database triggers, which are written in a postgres-typescript extension
[09:42:26] Prutheus: Hello. I am using sidekiq and want to use that method https://github.com/mperham/sidekiq/wiki/FAQ#how-do-i-cancel-a-sidekiq-job to cancel a job. But how do I call the cancel! method on the job, because when i do `job = TaskWorker.perform_async('bob', 5)` job is only the jid string ...
[09:54:43] dang`r`us: dminuoso, this project's old backend is nodejs too, of course. Anything resembling configuration management is a few incoherent bash scripts
[09:55:50] dminuoso: dang`r`us: I mean when I pick a language to solve a task, I think about "what strengths does this language have". What makes it so much better at this job than other languages. What abstractions/features does this language have to write better code in..
[09:56:00] dang`r`us: in fact I'm pretty close to develop a test script that does some sed on a gitlab configuration file (because currently "deploy this commit to the test server" is not a thing this monster can do)
[09:58:01] dang`r`us: I mean, I find JS actually pretty impressive given it was thrown together in 10 days or so
[09:58:50] dang`r`us: but anyway, no, I guess I don't know the reason behind every number being a float
[09:59:47] dminuoso: dang`r`us: As far as I know, it's mostly related to this 10 day hacking course where it was easier to have fewer things, and somehow magically have things coerce into each other..
[11:37:02] xco: hi i just created a new rails project, cd’ed into it and run ‘$ rails g scaffold Book name:string cover:binary’ but it stuck and is not generating anything. i’m using R5.2 and ruby 2.5 any ideas where to look?
[12:08:16] dminuoso: Radar: https://github.com/dry-rb/dry-core/commit/14d18f23cd715d552ac589a67b2289835be43caa
[12:08:39] dminuoso: Im not even remotely surprised that this might not interact nicely with autoloading.
[13:23:48] yebyen: hmm! so I was at RailsConf this past week and heard a talk about multiple databases in Rails
[13:25:41] yebyen: and I was thinking back to my last job and the replicating mysql databases we had, without which we could not have operated at the scale that we did!
[13:26:35] yebyen: my app will probably have 10 concurrent users max peak and they will each operate on mostly just a single record at a time
[13:27:04] yebyen: but i was coming to see if anyone uses the octopus gem since that seems to be the answer to my question
[13:27:34] yebyen: "how do I send Read operations to a slave and Write operations to the master, unobtrusively through AR"
[13:27:57] yebyen: https://medium.com/kkempin/postgresql-master-slave-replication-on-heroku-with-ruby-on-rails-bf0eb8d69fe
[13:28:35] yebyen: it means that I don't need to build separate UserReader and UserWriter models that point at separate databases
[13:29:20] yebyen: I can just do "User.where" and Rails recognizes that i'm trying to read, so I need the read slave
[13:29:53] yebyen: but if I do "User.new" it says hey, you need to write? i'll send you to the master for writes
[13:34:18] yebyen: anyway I just wanted to talk about it with someone before I go make an issue on github/rails/rails
[14:19:21] pushcx: Is there any way to add to the columns selected by a query? .select() replaces them so scopes can't compose. I can't find any activerecord/arel docs of select, though it seems like it might be possible by really digging deep into arel internals.
[15:28:32] context: writing a gem, anyone know a good way to test the library loads without dev dependencies ?
[15:29:56] context: we just hit an issue that someone accidnetally require'd dev dep on the library. everything was peachy in tests, and our rails app that loaded the gem in dev
[15:41:24] apeiros: you are not refering to cloning one gem, you're referring to create the service rubygems.org provides?
[15:54:46] acovrig: I’m POSTing a JSON object to a rails instance, I can JSON.parse(request.raw_post) but that feels wrong, shouldn’t I be able to access the params object, if I p params, I get a stringified version of my object => “” as a single parameter, how do I fix this?
[16:20:34] timdotrb: I’m trying to create a catch all for errors (specifically 404), but when I send a json request, I’m getting html. I’ve tried adding format.js and format.json responders to no avail. Any ideas why? https://gist.github.com/willc0de4food/84f86c04411491e3b5ef85bd29528257
[16:30:10] deathwishdave: is there any such thing a as accredition or stamp that states your web application is secure?
[17:05:49] darkhanb: Is there anything equivalent to Django's gettext_noop in Rails? I'm trying to figure out how to do the dynamic translations: https://dpaste.de/atB3/raw
[18:10:37] c0lored: Hello, I am getting an error when trying to run "rails s" in the root of my application., well not really my application, an application that was created 5 or 6 years ago.
[18:22:51] mrtroy32: agreed. I'd check the .ruby-version file to make sure rvm is running the right version
[18:26:42] c0lored: i have been tasked with updating a server running 3 apps that were written in the ancient time of rails 2.3.5
[18:27:01] c0lored: i have been trying to get these apps to run on the newest stack but was not having luck with rails 5.2
[18:27:48] c0lored: so i decided to run rails 2.3.5 on top of the newer ruby, have crushed most bugs that have popped up. there will be more since the apps used the "mysql" gem which is no longer maintained.
[18:27:50] syndikate: When I compare a date object and a time object what happens? I mean how does the conversion and comparison happen?
[18:28:26] c0lored: i have installed and replaced all instances of require 'mysql' with require mysql2
[19:00:39] rikkipitt: hi folks, i've got a products controller, but i want to have a separate mini form for a subset of fields that cn be updated separately (remote: true)
[19:01:05] rikkipitt: should i create a separate controller? if so, what do you name these sub/related controllers?
[19:36:42] timdotrb: I’m trying to create a catch all for errors (specifically 404), but when I send a json request, I’m getting html. I’ve tried adding format.js and format.json responders to no avail. Any ideas why? https://gist.github.com/willc0de4food/84f86c04411491e3b5ef85bd29528257
[19:42:39] steerio: Hi all, I'm working on someone else's Rails project and my knowledge is rusty. Do I have to do any asset precompilation in development mode?
[19:43:16] steerio: Project runs in production mode on Heroku, but fails in dev mode with a Sprockets::FileNotFound on a require line in a css file
[19:46:18] steerio: interestingly, it fails on "foundation" and "jquery", obviously as neither foundation-rails nor jquery-rails are even mentioned in the Gemfile - but then how can it run in production?
[20:22:13] c0lored: Hello, when trying to run my application via "rails s" I am getting a cannot load such file error. Please see paste bin for excerpts.
[20:40:40] dang`r`us: c0lored, when I google for "cannot load such file -- initializer (LoadError)" I get some info
[20:41:41] c0lored: yea, i have gone through all those google results, and can't see to find a solution that will work for me.
[21:34:13] daveomcd: anyone know why my assets/fonts/*.tff files aren't being loaded to my production server? I've included config.assets.paths << Rails.root.join("app","assets","fonts") to my application.rb - but when i load the page i still get 404 not found. Whereas it loads fine in development server