« Back to channel list

#RubyOnRails - 30 July 2018

« Back 1 day Forward 1 day »
[00:04:14] wwalker: PEBKAC - it was downloading the csv, but of course doesn't change the old error messages on the browser. Thanks Radar
[00:09:06] wwalker: What is the defacto way to serve Rails these days? I last deployed rails 2....
[00:09:41] Radar: The hipsters would tell you to use Amazon EKS... but I'm a traditionalist and would use Heroku or a VPS instead.
[00:10:22] wwalker: I have a server, Passenger? something replaced it?
[00:10:32] Radar: Passenger is still used I think.
[00:10:45] Radar: Lots of people just have nginx serving as a proxy to unicorn/puma these days though.
[00:13:32] wwalker: ACTION eyes the kk-pwin 135 pressure washer on amazon
[00:46:00] chouhoulis: has joined #RubyOnRails
[00:56:21] mroutis: has left #RubyOnRails: ()
[01:00:35] alfiemax: has joined #RubyOnRails
[01:01:00] mroutis: has joined #RubyOnRails
[01:43:25] tdy: has joined #RubyOnRails
[01:49:16] spohnz: has joined #RubyOnRails
[02:07:38] sevenseacat: has joined #RubyOnRails
[02:12:23] beilabs: has joined #RubyOnRails
[02:26:59] akaiiro: has joined #RubyOnRails
[02:38:42] Caerus: has joined #RubyOnRails
[03:10:07] braincrash: has joined #RubyOnRails
[03:12:48] eckhardt: has joined #RubyOnRails
[03:16:42] Saukk: has joined #RubyOnRails
[03:23:11] alfiemax: has joined #RubyOnRails
[03:25:00] srinidhi: has joined #RubyOnRails
[03:38:52] chouhoulis: has joined #RubyOnRails
[03:42:52] za1b1tsu: has joined #RubyOnRails
[04:02:22] tdy: has joined #RubyOnRails
[04:32:50] fryguy: has joined #RubyOnRails
[04:46:33] duderonomy: has joined #RubyOnRails
[05:11:03] duderonomy: has joined #RubyOnRails
[05:22:51] srinidhi: has joined #RubyOnRails
[05:23:52] ur5us: has joined #RubyOnRails
[05:47:57] segy: has joined #RubyOnRails
[06:17:55] snickers: has joined #RubyOnRails
[06:26:25] duderonomy: has joined #RubyOnRails
[06:27:36] DoubleMalt: has joined #RubyOnRails
[06:30:37] conta: has joined #RubyOnRails
[06:32:59] nemesit: has joined #RubyOnRails
[06:37:04] Liothen: has joined #RubyOnRails
[06:38:09] tpendragon: has joined #RubyOnRails
[06:39:05] wethu: has joined #RubyOnRails
[07:07:51] reber: has joined #RubyOnRails
[07:24:08] lexileo: has joined #RubyOnRails
[07:34:41] psychoslave: has joined #RubyOnRails
[07:35:04] Technodrome: has joined #RubyOnRails
[07:47:00] mikecmpbll: has joined #RubyOnRails
[07:51:46] Technodrome: has joined #RubyOnRails
[07:52:33] exadeci: has joined #RubyOnRails
[07:54:59] wethu: has joined #RubyOnRails
[07:55:09] exadeci: Hello, I'm upgrading a project from Rails 4 to 5 and I'm having an odd issue.
[07:55:09] exadeci: While Capybara is rendering a view that has `formats: :json` it ignores it and tries to find an html one, but if I replace :json by :xml for example it follows it and tries to find an xml view... (the view is a jbuilder view)
[07:57:01] sevenseacat: can you show this happening? eg. in server logs or the like
[08:02:11] exadeci: sevenseacat: Yes just a sec
[08:04:34] exadeci: https://gist.github.com/exadeci/7dc438d343d91a7148f4acef5a72b9c0
[08:05:54] Radar: ":formats=>[:html]"
[08:06:15] Radar: app/helpers/graph_cards_helper.rb:14 plz kthx
[08:06:30] Radar: And app/controllers/application_controller.rb:52
[08:07:34] exadeci: I've added the logs of the same test when I specify :xml
[08:12:04] exadeci: Radar: I've updated the gist with the methods that are on those lines
[08:12:59] sevenseacat: format, not formats
[08:13:09] sevenseacat: in your helper
[08:14:16] conta: has joined #RubyOnRails
[08:14:45] wethu: has joined #RubyOnRails
[08:19:06] exadeci: sevenseacat: It's formats and not format, now thank you for your time but I've actually figured it out (rubber ducking much?), I just failed to read the logs. While it complains about the template format on the helper at the bottom of the logs it says that it was caused by line 2 of the jbuilder file which is loading another view, forcing it to :json there fixes this issue
[08:20:33] sevenseacat: oh really? TIL. weird but fair enough!
[08:21:05] sevenseacat: (why would specifying multiple formats ever be useful?)
[08:22:07] exadeci: sevenseacat: If your backend can be a front end loading html views or also work as an api?
[08:22:07] exadeci: Also it's format in the routes so you might have thought of this one
[08:23:29] sevenseacat: uh... I must be misunderstanding what its for then
[08:26:24] jottr: has joined #RubyOnRails
[08:37:41] srinidhi: has joined #RubyOnRails
[08:40:17] ur5us: has joined #RubyOnRails
[08:46:36] wethu: has joined #RubyOnRails
[08:52:44] ur5us: has joined #RubyOnRails
[09:03:00] Ergo: has joined #RubyOnRails
[09:11:56] duderonomy: has joined #RubyOnRails
[09:23:04] sirensari2: has joined #RubyOnRails
[09:24:39] wethu: has joined #RubyOnRails
[09:33:23] mikecmpb_: has joined #RubyOnRails
[10:20:53] GodFather: has joined #RubyOnRails
[10:26:10] srinidhi: has joined #RubyOnRails
[10:26:56] Dbugger: has joined #RubyOnRails
[10:31:41] schneider: has joined #RubyOnRails
[10:43:52] GodFather: has joined #RubyOnRails
[10:49:16] wethu: has joined #RubyOnRails
[10:52:41] TvL2386: has joined #RubyOnRails
[10:54:43] srinidhi: has joined #RubyOnRails
[11:05:31] GodFather: has joined #RubyOnRails
[11:15:35] schneider: has joined #RubyOnRails
[11:23:31] GodFather: has joined #RubyOnRails
[11:31:06] rikkipitt: has joined #RubyOnRails
[11:31:50] za1b1tsu: has joined #RubyOnRails
[11:42:56] apparition47: has joined #RubyOnRails
[11:51:28] wethu: has joined #RubyOnRails
[11:56:37] conta: has joined #RubyOnRails
[12:19:07] ellcs: has joined #RubyOnRails
[12:19:11] tmm88: has joined #RubyOnRails
[12:19:31] dblessing: has joined #RubyOnRails
[12:30:08] nzst: has joined #RubyOnRails
[12:39:14] jasmith: has joined #RubyOnRails
[12:45:35] ciro: has joined #RubyOnRails
[12:48:13] GodFather: has joined #RubyOnRails
[12:49:25] srinidhi: has joined #RubyOnRails
[12:51:07] rikkipitt: has joined #RubyOnRails
[13:00:27] jottr: has joined #RubyOnRails
[13:02:54] mikecmpbll: has joined #RubyOnRails
[13:07:24] crankhar1er: has joined #RubyOnRails
[13:08:02] psychoslave: has joined #RubyOnRails
[13:08:54] IanMalcolm: has joined #RubyOnRails
[13:17:34] srinidhi: has joined #RubyOnRails
[13:22:15] sirensari2: has joined #RubyOnRails
[13:22:17] rikkipitt: has joined #RubyOnRails
[13:33:09] zmo: hi there o/
[13:33:41] snowy: has joined #RubyOnRails
[13:35:34] sirensari2: just discovered that my new favorite gem is maintained by fetlife
[13:35:50] sirensari2: https://github.com/fetlife/rollout
[13:36:14] zmo: I got a quick question about active records, if I filter out results on a query, but I do a `select` on it to filter out some results, will activerecord transform the query into array (i.e.: wait for all the results to be selected and then apply the `select()` ?), or will it work like an iterator, and apply the `select` as the query is returning results ?
[13:36:33] zmo: hum… shouldn't rewrite the question as I'm writing it, it's not very clear
[13:37:11] zmo: take 2:
[13:37:13] zmo: I got a quick question about active records : I want to filter out results on a query using `select` because I need to. Will activerecord transform the query into array (i.e.: wait for all the results to be selected and then apply the `select()` ?), or will it work like an iterator, and apply the `select` as the query is returning results ?
[13:38:01] sirensari2: how does that equate to it being an array
[13:38:36] TvL2386: zmo: I'm not following you...
[13:38:44] TvL2386: how do you filter?
[13:39:46] TvL2386: ActiveRecord builds a query based on the methods you call on your object. That query can be inspected by calling #to_sql
[13:39:58] zmo: User.where(condition: true).select { |u| u.that_other_condition != another_value }
[13:40:04] zmo: here's an example
[13:40:12] TvL2386: .select is from the Enumerable class
[13:40:34] TvL2386: so that has nothing to do with ActiveRecord. ActiveRecord has fired the query when you call .select
[13:40:44] zmo: will select be applied to each tuple as soon as the query can iterate over a new row ? or will it wait for the query to end and then apply the select on the whore array ?
[13:41:23] TvL2386: yeah you are looping through all users, keeping the once that match your condition
[13:41:34] TvL2386: all users with "condition: true" I mean
[13:41:41] TvL2386: and then test them all for that second condition
[13:41:47] TvL2386: discarding the ones not matching it
[13:42:41] sirensari2: zmo, don't do that
[13:43:05] sirensari2: use where.not
[13:43:06] TvL2386: I think you should/could do: User.where(condition: true).where.not(:that_other_condition: another_value)
[13:43:36] TvL2386: made a Symbol syntax error there, but you get the gist I think :)
[13:43:57] zmo: yup, that's indeed what it does, but the question is whether it's in a sequence of two : (1) load the one gazillion rows (2) wait while the query is complete and load it all in memory (3) apply select on the array loaded in memory
[13:44:12] zmo: s/of two //
[13:44:24] TvL2386: zmo: you build a Relation object and the results are only retrieved when you are actually starting to do something with the result
[13:44:47] zmo: so technically `.select { |u| ... }` is that something ?
[13:45:00] TvL2386: you can do: u = User ; u=u.where(bla) ; u=u.where(bla2) ; u.each { |user| ... }
[13:45:08] TvL2386: only when calling .each the query is fired
[13:45:23] TvL2386: on the road you can inspect the query changing by calling u.to_sql in the mean time
[13:45:38] zmo: yup, I know that `.select` is not part of SQL
[13:45:55] TvL2386: https://ruby-doc.org/core-2.5.1/Enumerable.html#method-i-select
[13:46:18] TvL2386: .select causes the query to fire and ActiveRecord User instances to be populated
[13:46:55] zmo: my question is how it behaves : as the query returns results, is it feeding each row to the `select` method like an iterator does
[13:47:09] sirensari2: zmo, do you want it to
[13:47:09] TvL2386: that's exactly what it does
[13:47:15] zmo: or does it wait for the query to complete and then apply the select on the result
[13:47:20] zmo: ok thank you :)
[13:47:29] sirensari2: so would .load
[13:47:31] TvL2386: sirensari2: zmo already know what he wants, he wants to use: User.where(...).where.not(....)
[13:47:45] zmo: now my precise use case that makes it impossible to use `where.not()`
[13:48:16] TvL2386: ah, maybe we can help you if you show us your real usecase
[13:48:27] sirensari2: i like hearing about edge cases
[13:49:14] zmo: it's that I got in redis (`Rails.cache`) records of results I want to skip, so what I really do is : User.where(whatever).select{ |u| not Rails.cache.fetch("/user/#{u.id}") }
[13:50:06] zmo: and I got good reasons to not keep that information in redis and not in database (because it's transcient, temporary and a very specific edge case)
[13:50:14] TvL2386: Usere.where(whatever).where.not(id: Rails.cache.fetch("get my user ids in an Array")
[13:50:30] TvL2386: now your are calling redis for every User
[13:50:43] fmcgeough: has joined #RubyOnRails
[13:52:01] zmo: hm… not that easy, because I cannot put a timeout on a write into an array element
[13:52:33] zmo: but maybe I can cheat, using a '/user/*' query if rails.cache allows it
[13:52:41] zmo: (and write the id as value)
[13:52:46] zmo: TvL2386 - thanks for the idea
[13:52:54] TvL2386: zmo you're welcome :)
[13:53:18] TvL2386: also, maybe check out the ransack gem. It's one that I tend to use a lot with searching and filtering
[13:53:24] zmo: but /knowing/ that query.select behaves as an iterator is also a good thing to know
[13:53:37] zmo: that means I don't need that optimization yet
[13:53:38] TvL2386: it will give you: User.where(whatever).id_not_in([1,2,3,4])
[13:54:14] TvL2386: all you know now: You're query fetches too many users and for every user you will have to query Redis
[13:54:20] TvL2386: which sounds like a bad practice
[13:54:39] TvL2386: especially the latter part
[13:55:00] zmo: of course, but the good thing is that I'm actually not fetching a gazillion items, just a few hundreds, and if each row takes a tiny bit more I can take it
[13:55:16] zmo: but I got to wait for the whole query to end, that I can't :)
[13:56:07] TvL2386: it's nasty and last resort imho, but you can always query redis yourself
[13:56:26] TvL2386: good luck :)
[13:57:10] TvL2386: and zmo, don't confuse the Enumarable select with the one from ActiveRecord that only selects certain keys from the tables
[14:03:33] zmo: of course not, I'm totally aware that `.select` is part of the ruby interface of Enumerable
[14:03:48] zmo: which was why my question was so precise ☺
[14:04:31] srinidhi: has joined #RubyOnRails
[14:08:22] TvL2386: zmo ok sorry, I must admit myself that I don't really know where that #select from ActiveRecord is defined. I don't know if you can call it on the ActiveRecord::Relation object, but I'm not working the problem currently :)
[14:09:02] TvL2386: I should investigate, so it's my limitation. Just wanted to inform you in case you don't know/are not wondering
[14:34:09] dviola: has joined #RubyOnRails
[14:39:45] akaiiro: has joined #RubyOnRails
[14:59:10] ams__: has joined #RubyOnRails
[14:59:12] GodFather: has joined #RubyOnRails
[15:04:00] conta1: has joined #RubyOnRails
[15:13:55] srinidhi: has joined #RubyOnRails
[15:21:27] GodFather: has joined #RubyOnRails
[15:23:22] mattwalston: has joined #RubyOnRails
[15:30:01] Cork: has joined #RubyOnRails
[15:35:20] Cork: has joined #RubyOnRails
[15:39:12] spohnz: has joined #RubyOnRails
[15:44:45] alfiemax: has joined #RubyOnRails
[15:46:31] regedit: has joined #RubyOnRails
[15:47:20] spohnz: has joined #RubyOnRails
[15:47:28] Technodrome: has joined #RubyOnRails
[15:48:51] Saukk: has joined #RubyOnRails
[15:48:55] spohnz: has joined #RubyOnRails
[15:51:51] Cork: has joined #RubyOnRails
[15:52:22] havenwood: has joined #RubyOnRails
[15:55:20] spohnz: has joined #RubyOnRails
[15:57:16] srinidhi: has joined #RubyOnRails
[15:59:42] krawchyk: has joined #RubyOnRails
[16:00:32] ivanskie: has joined #RubyOnRails
[16:04:19] IanMalcolm: has joined #RubyOnRails
[16:04:50] cagomez: has joined #RubyOnRails
[16:07:49] GodFather: has joined #RubyOnRails
[16:11:25] lxsameer: has joined #RubyOnRails
[16:15:27] troys: has joined #RubyOnRails
[16:21:35] darkhanb: has joined #RubyOnRails
[16:23:37] chouhoulis: has joined #RubyOnRails
[16:27:03] GodFather: has joined #RubyOnRails
[16:34:16] Andr3as: has joined #RubyOnRails
[16:35:46] dviola: has joined #RubyOnRails
[16:38:35] alfiemax_: has joined #RubyOnRails
[16:49:05] eckhardt_: has joined #RubyOnRails
[16:50:18] deathwishdave: has joined #RubyOnRails
[17:03:00] mattwalston: has joined #RubyOnRails
[17:03:21] mattwalston: Anyone know of articles or thoughts relating to long-term usage of Asset Pipeline vs webpacker gem? I'm looking forward to a new project and can see either meeting our needs. We will likely use Stimulus and appreciate es6 but unsure of we are ready to --skip-sprockets. Thoughts?
[17:05:26] ellcs: has joined #RubyOnRails
[17:05:33] nzst: mattwalston: i use both
[17:05:54] nzst: at the same time
[17:07:57] beowuff: has joined #RubyOnRails
[17:23:46] za1b1tsu: has joined #RubyOnRails
[17:25:52] SteenJobs: has joined #RubyOnRails
[17:30:31] Technodrome: has joined #RubyOnRails
[17:33:25] scrptktty: has joined #RubyOnRails
[17:35:06] dviola_: has joined #RubyOnRails
[17:36:17] mattwalston: nzst: Thank you. That will likely be my strategy for now.
[17:39:10] krawchyk: has joined #RubyOnRails
[17:39:28] akaiiro: has joined #RubyOnRails
[17:59:13] augcesar: has joined #RubyOnRails
[18:00:19] Caerus: has joined #RubyOnRails
[18:01:53] SteenJobs: has joined #RubyOnRails
[18:11:56] dblessing: has joined #RubyOnRails
[18:13:12] samosaphile: has joined #RubyOnRails
[18:13:20] orbyt_: has joined #RubyOnRails
[18:17:06] Inside: has joined #RubyOnRails
[18:17:44] mjacob: what would be a good way to test a feature of a layout template, e.g. some feature which is common to all pages?
[18:18:31] mjacob: so far i've used some thing like ``render template: "layouts/application"``, but it doesn't work if the layout template contains something like url_for
[18:24:34] GodFather: has joined #RubyOnRails
[18:49:45] deathwishdave: has joined #RubyOnRails
[19:18:24] ryandv: has joined #RubyOnRails
[19:20:18] ryandv: so I'm noticing that there is such a thing as the `@association_cache` in `ActiveRecord::Associations`. under what circumstances is this cache expired? I am experiencing issues after upgrading to Rails 5 from 4.2 where a transaction is rolled back, but instances of ActiveRecord still have their `@association_cache` pointing to stale objects
[19:20:45] ryandv: I suppose that one solution would be to just reload all records in the event of a rollback, but I'd like to understand more
[19:23:02] ryandv: in particular, I don't think we've encountered stale reads when navigating an association in 4.2, so I'm curious if anyone has any ideas on what change in rails 5 would cause this difference in behaviour
[19:31:17] deathwishdave: has joined #RubyOnRails
[19:32:53] nzst: This thread seems relevant, https://stackoverflow.com/questions/18268896/how-do-i-force-rails-to-not-use-a-cached-result-for-has-many-through-relations , I think there is a #clear_association_cache method
[19:33:31] prettybTech: has joined #RubyOnRails
[19:33:35] krawchyk: has joined #RubyOnRails
[19:34:25] ryandv: nzst: seems quite relevant. thanks, i'll take a closer look at that
[19:37:32] snickers: has joined #RubyOnRails
[19:56:23] Eindoofus: has joined #RubyOnRails
[19:59:54] Technodrome: has joined #RubyOnRails
[20:06:23] deathwishdave: has joined #RubyOnRails
[20:17:10] SteenJobs: has joined #RubyOnRails
[20:31:25] prettybTech: has joined #RubyOnRails
[20:58:27] johndunn: has joined #RubyOnRails
[21:04:44] krawchyk: has joined #RubyOnRails
[21:06:52] npgm: has joined #RubyOnRails
[21:06:53] Sylario: has joined #RubyOnRails
[21:16:01] alfiemax: has joined #RubyOnRails
[21:26:02] johndunn: has left #RubyOnRails: ()
[21:26:50] Technodrome: has joined #RubyOnRails
[21:42:29] eckhardt_: has joined #RubyOnRails
[21:45:33] lexileo: has joined #RubyOnRails
[21:50:56] kapil___: has joined #RubyOnRails
[21:54:20] eckhardt_: has joined #RubyOnRails
[21:58:35] prettybTech: has joined #RubyOnRails
[21:59:16] deathwishdave: has joined #RubyOnRails
[22:03:18] eckhardt_: has joined #RubyOnRails
[22:18:35] wethu: has joined #RubyOnRails
[22:27:26] ciro: has joined #RubyOnRails
[22:46:39] sirensari2: has joined #RubyOnRails
[22:56:12] eckhardt_: has joined #RubyOnRails
[23:05:51] snowy: has joined #RubyOnRails
[23:13:03] orbyt_: has joined #RubyOnRails
[23:29:36] fcser_: has joined #RubyOnRails
[23:32:21] wethu: has joined #RubyOnRails
[23:42:39] eckhardt_: has joined #RubyOnRails
[23:47:02] eckhardt_: has joined #RubyOnRails
[23:53:10] IanMalcolm: has joined #RubyOnRails