#RubyOnRails - 31 January 2019
« Back 1 day Forward 1 day »
[00:15:13] baweaver: Things that work locally on sqlite3 may not work in prod/staging, breaking parity of environments and exposing a potential for bugs.
[00:16:01] baweaver: _Especially_ if feature parity comes into play enough to make multiple schemas come up as a solution idea.
[08:21:14] marahin: Hi. I'm working on a Rails application. A service object I'm creating uses Tempfiles to download and then do something with files. The Tempfiles seem to work properly on development, however, in integration tests they always can't seem to be created, because the `Dir.tmpdir` doesn't have a `test/` subdirectory, in which the Tempfile is trying to be created.
[08:21:34] marahin: Even if I pass custom temporary directory it still tries to put it in `test/` subdirectory.
[16:46:29] yoshie902a: Ruby Sass is deprecated and will be unmaintained as of 26 March 2019., What is replacing it in rails?
[16:50:57] yoshie902a: are they just removing it completely, or are the replacing it with something else. I see SASSC is mentioned, but it just says I can add it.
[16:53:33] havenwood: yoshie902a: Rails actually depends on sass-rails, not sass. Here's a patch adding sassc support to sass-rails: https://github.com/rails/sass-rails/pull/349/files
[16:56:18] Net: havenwood: certain recommendations seem to suggest that only generic (non-business logic, that is) code should go in lib/
[16:57:01] havenwood: Net: Think of it as temporary housing for something that should really live in a Gem.
[16:57:17] Net: havenwood: what is your take on https://codeclimate.com/blog/what-code-goes-in-the-lib-directory ?
[17:00:10] Net: my greater question is where to put domain code that isn't a model or controller or policy or service, etc.
[17:00:11] havenwood: Net: https://www.justinweiss.com/articles/a-guide-to-extracting-your-first-ruby-gem/
[17:01:58] Net: I have an "Event" class that isn't persisted in the database, but in one of its methods makes a call to the database
[17:03:36] havenwood: Net: Models don't have to be persisted. ActiveModel explicitly allows it: def persisted; false end
[17:04:37] Net: what's the use of a model that isn't persisted or interfaces directly with user input (no need for forms or validations)?
[17:04:47] havenwood: Net: There're probably better examples, but here's one: https://rubyplus.com/articles/3771-Tableless-Model-in-Rails-5
[17:05:26] havenwood: Net: The same type of use as an Event model that isn't persisted to the db, but makes a call to the db.
[17:06:22] Net: I mean, what's the benefit of inheriting from ActiveRecord::Base/ApplicationRecord in such cases?
[17:12:48] Net: it makes a database call to load another, but it itself doesn't need to be a model for that
[17:17:40] Net: havenwood: this is all it is right now https://gist.github.com/net/f2166689bd56a66bb694fdcfbc0d4511
[17:21:05] havenwood: Net: If you've already gone down the services route, this seems like a fine service. Just do a function rather than instances.
[17:31:05] bruce_lee: net: I understood only a little bit of the conversation, but I consider communication netween more advanced programmers as helpful to me
[17:31:27] havenwood: Net: I'd say the Rails docs are a great resource. Otherwise, keep asking questions. You'll get a variety of answers.
[17:43:55] andywww: when spitting out the different variants on active storage, i’ve read its not ideal to call variant in the view as its render blocking
[17:44:26] andywww: at the risk of sounding stupid, where else would you call it? it seems a bit excessive making ajax calls for them?
[18:17:05] yoshie902a: Is it possible to create an array field with the rails generator? “t.string, :A_options array: true, default: ”
[18:27:18] yoshie902a: What is the difference with migrations between: “t.string, :A_options array: true, default: ” and “t.array, :A_options” when using postgres
[18:55:14] yoshie902a: Not sure, I don’t know the difference, and wanted to understand before a chose a solution.
[18:57:29] Net: t.array, :A_options will try to create a column with the type "array", which does not exist in postgres
[18:58:01] Net: the former will try to create a column with the type "string" (an array of strings) which does exist
[20:03:58] bruce_lee: yoshie902a: I would prefer to put something in the css files: @font-face -> font-family -> src
[20:04:45] cschneid: Is there a nicer way to do `user.created_at < 10.minutes.ago` to find older users?
[20:07:30] cschneid: sorry, my question was sorta bad - I mean to do time comparisons like that in ruby, not any sql. Is there a helper like `.created_at.before?(10.minutes.ago)` or something?
[20:07:31] bruce_lee: yoshie902a: then I guess a gem might be the easiest solution, but loading all the icons is not really leight-weight
[20:15:49] tpanarch1st: good evening, i'm just getting started with Rails, bit shattered but I thought i'd start having a go at building the blog. https://guides.rubyonrails.org/getting_started.html - this says "To use this generator, open a terminal, navigate to a directory where you have rights to create files, " i'm not sure how to do this or quite how that bit works :)
[20:56:00] yoshie902a: I am still a bit confused the the depreciation of SASS in rails, but does that mean that gem 'sass-rails’, won’t work in the future and I need another gem?
[20:57:14] yoshie902a: I am planning to use gem 'bootstrap', '~> 4.2.1' and don’t want issues with depreciated features. Advise to avoid future issues please. What SASS or SASSC gem do I need?
[21:01:04] yoshie902a: I see I can put gem 'sassc-rails' in its place, but does that mean I need to install a version of C?
[21:19:36] havenwood: cschneid: I guess there are a variety of ways of writing it but one isn't jumping out at me.
[21:20:08] cschneid: havenwood: thanks - mostly wanted to use a word based method to avoid the "do I use > or < for this" type error.
[21:31:02] tpanarch1st: hi, when you install rails, how do you know which directory to navigate to to create files please
[21:35:10] tpanarch1st: radar, please would you have a look at my bash terminal output from the install to see if there are any issues?
[21:35:37] helpa: tpanarch1st: http://gist.github.com - Put your codes online with pretty syntax highlighting and the ability to embed it into other pages.
[21:36:43] tpanarch1st: there you go Radar https://gist.github.com/greenlanegreb/cd80c4c4d504700e6bc4ab5a676bf35f - thanks :)
[21:37:23] Radar: I think you'll be fine with just Ruby 2.6 installed. I am not sure why you also installed Ruby 2.4.5
[21:38:22] Radar: tpanarch1st: your "gem install" appears to have installed Rails 5.0 but it thje latest version is 5.2.somehting
[21:39:13] tpanarch1st: i figured i'd make notes of the output as i'm totally new to coding really - i've watched tons of tutorials over the years but never really made anything :)
[21:40:27] tpanarch1st: i've been looking forward to having a play for a while but just been busy with my voluntary work - January rush! -> I can't remember how I came across that link - i just ended up using it but then discovered ruby website has a lot of it's own!
[21:40:38] Radar: tpanarch1st: "gem install rails" should install Rails 5.2.2. You can verify it by running `rails -v`, it should show 5.2.2
[21:41:02] Radar: tpanarch1st: oh right :) it's just that I've visited coder academy a few times as a guest speaker. I was wondering if you were one of the students
[21:41:35] tpanarch1st: oh! No, I just found the instructions friendly enough - I didn't have a clue what I was doing really, I think I ran the instructions past the #ruby channel just to make sure there was nothing malicious!
[21:42:21] Radar: tpanarch1st: the latest version should take precedence. Then when you generate a Rails app, there's a file called "Gemfile" which specifies exactly which versions to use
[21:43:50] tpanarch1st: ok :) it's a steep learning curve, so what would the command be to remove the old one to put the one on that you are recommending please?
[21:45:55] tpanarch1st: so it didn't prompt me for anything uninstalling but it said it had uninstalled it all the same
[22:14:52] walidvb: i'd like to have an example file file that runs the test at once, all in one file
[22:15:45] walidvb: the issue i am having is that it seems that have a model with counter_culture on an STA model calls the UPDATE COUNTER twice
[22:16:09] walidvb: i'd like if possible to avoid having a full repo just for that test case, but rather have one file that can rune
[23:32:34] walidvb: nvm, found it: https://christoph.luppri.ch/articles/rails/single-file-rails-applications-for-fun-and-bug-reporting/