« Back to channel list

#RubyOnRails - 24 January 2019

« Back 1 day Forward 1 day »
[00:05:05] tdy: has joined #RubyOnRails
[00:13:47] cdabba: has joined #RubyOnRails
[00:23:54] chouhoulis: has joined #RubyOnRails
[00:31:48] skryking: has joined #RubyOnRails
[00:42:08] orbyt_: has joined #RubyOnRails
[00:52:23] eean: has joined #RubyOnRails
[01:19:27] blackmesa: has joined #RubyOnRails
[01:28:54] sagax: has joined #RubyOnRails
[01:35:23] egray: has joined #RubyOnRails
[01:51:50] chouhoulis: has joined #RubyOnRails
[01:54:41] brandoncc: has joined #RubyOnRails
[02:07:49] cpruitt: has joined #RubyOnRails
[02:19:15] sevenseacat: has joined #RubyOnRails
[02:19:52] cpruitt: has joined #RubyOnRails
[02:27:19] salasrod: has joined #RubyOnRails
[02:30:26] salasrod: has joined #RubyOnRails
[02:35:05] salasrod: has joined #RubyOnRails
[02:35:50] salasrod: has joined #RubyOnRails
[02:51:57] Saukk: has joined #RubyOnRails
[03:20:52] tdy: has joined #RubyOnRails
[03:23:51] krawchyk: has joined #RubyOnRails
[03:36:22] cpruitt: has joined #RubyOnRails
[03:37:26] chouhoulis: has joined #RubyOnRails
[03:37:56] andrewray: has joined #RubyOnRails
[03:39:06] salasrod: has joined #RubyOnRails
[03:46:45] salasrod: has joined #RubyOnRails
[03:52:01] bga57: has joined #RubyOnRails
[03:52:03] salasrod: has joined #RubyOnRails
[03:57:56] cpruitt: has joined #RubyOnRails
[04:03:11] tdy: has joined #RubyOnRails
[04:09:02] braincrash: has joined #RubyOnRails
[04:10:00] agent_white: has joined #RubyOnRails
[04:11:33] fragamus: has joined #RubyOnRails
[04:36:56] cpruitt: has joined #RubyOnRails
[04:43:37] NeXTSUN: has joined #RubyOnRails
[04:54:38] cpruitt: has joined #RubyOnRails
[05:34:06] jtperreault: has joined #RubyOnRails
[05:34:48] FooBarWidget: has joined #RubyOnRails
[05:40:36] cpruitt: has joined #RubyOnRails
[05:56:27] cpruitt: has joined #RubyOnRails
[06:10:20] skryking: has joined #RubyOnRails
[06:14:55] Jervis_: has joined #RubyOnRails
[06:17:53] dionysus69: has joined #RubyOnRails
[06:24:04] kapil____: has joined #RubyOnRails
[06:34:28] tdy: has joined #RubyOnRails
[06:36:45] srinidhi: has joined #RubyOnRails
[06:47:46] cpruitt: has joined #RubyOnRails
[06:54:58] reber: has joined #RubyOnRails
[06:55:45] srinidhi: has joined #RubyOnRails
[07:02:26] srinidhi: has joined #RubyOnRails
[07:26:30] tdy: has joined #RubyOnRails
[07:28:58] salasrod: has joined #RubyOnRails
[07:31:48] ariedler: has joined #RubyOnRails
[07:35:34] srinidhi: has joined #RubyOnRails
[07:45:52] srinidhi: has joined #RubyOnRails
[07:52:21] tdy: has joined #RubyOnRails
[08:06:18] cpruitt: has joined #RubyOnRails
[08:10:37] srinidhi: has joined #RubyOnRails
[08:23:26] Turnikov[m]: has joined #RubyOnRails
[08:37:49] tdy: has joined #RubyOnRails
[08:44:10] cpruitt: has joined #RubyOnRails
[08:50:09] Ergo: has joined #RubyOnRails
[08:53:02] Technodrome: has joined #RubyOnRails
[09:15:26] srinidhi: has joined #RubyOnRails
[09:16:08] srinidhi: has joined #RubyOnRails
[09:23:58] jacksop: has joined #RubyOnRails
[09:25:39] Guest16678: has joined #RubyOnRails
[09:28:11] GodFather: has joined #RubyOnRails
[09:32:38] ariedler: has joined #RubyOnRails
[09:38:53] srinidhi: has joined #RubyOnRails
[09:41:37] blackmesa: has joined #RubyOnRails
[09:42:44] schwad_: has joined #RubyOnRails
[09:43:26] Terens: has joined #RubyOnRails
[09:44:09] Terens: On the project I work for every request 600 rows are loaded for each request however app isn't very slow.
[09:44:20] cpruitt: has joined #RubyOnRails
[09:45:38] tbuehlmann: are you looking to slow down the requests? I can help with that
[09:46:41] blackmesa1: has joined #RubyOnRails
[09:47:57] Terens: no but I am always trying to make my code fast. However I did not expect doing such things and app to run fine.
[09:48:09] sevenseacat: databases are fast
[09:48:14] Terens: I cannot change that code since it is not mine
[09:48:29] Terens: Yes but loading 600 records into memory and rails
[09:48:37] sevenseacat: that's nothing
[09:48:51] sevenseacat: now if you were rendering HTML for 600 rows, that's a different story
[10:06:21] blackmesa: has joined #RubyOnRails
[10:08:40] mikecmpbll: has joined #RubyOnRails
[10:17:16] mauro1254: has joined #RubyOnRails
[10:32:59] mikecmpb_: has joined #RubyOnRails
[10:33:13] kidPalooma: has joined #RubyOnRails
[10:33:28] kidPalooma: Hello, can anybody answer this one? https://stackoverflow.com/questions/54331802/activejob-retry-on-callback-being-ignored
[10:36:00] fox_mulder_cp: terens: you can use redis for caching requests. in my app i have 3-4k+ items in database, but after full loading it in redis app answers for some seconds, not minutes %)
[10:37:55] cpruitt: has joined #RubyOnRails
[10:43:09] tbuehlmann: kidPalooma: could reproduce, I'm checking
[10:43:24] kidPalooma: tbuehlmann: thx
[10:55:38] tbuehlmann: kidPalooma: you're inheriting from Exception, but that should be StandardError
[10:56:22] kidPalooma: tbuehlmann: oh
[10:57:07] kidPalooma: isn't it a bit misleading that the docs call all the exceptions "[something]Exception" and not "[something] StandardError"?
[10:57:15] kidPalooma: lost quite a few hours on this
[10:58:13] catphish: has joined #RubyOnRails
[10:59:41] tbuehlmann: technically they are still exceptions, but that could probably be more clear. you could open up an issue for this
[11:23:43] IGnorAND: I'm trying to use database_cleaner to delete my db for the tests, is there a way to do rake db:seed RAILS_ENV=test after the db has been cleaned?
[11:29:14] IGnorAND: I think I found it. I can run Rails.application.load_seed in my Rspec.configure in config.before(:suite) do
[11:33:20] blackmesa: is anyone using Minitest with fixtures?
[11:33:46] ariedler: has joined #RubyOnRails
[11:34:00] blackmesa: I always clone my development db to the test db. After running any test, the test db only contains my fixtures
[11:34:02] DTZUZO_: has joined #RubyOnRails
[11:38:11] cpruitt: has joined #RubyOnRails
[11:41:26] mikecmpb_: blackmesa : yes
[11:41:41] blackmesa: hi mikecmpbll
[11:41:42] mikecmpbll: fixtures truncate the tables before inserting themselves
[11:41:58] mikecmpbll: if you use fixtures, your fixture data should be the only data your tests rely on
[11:42:05] mikecmpbll: (and data created during test runs)
[11:42:35] blackmesa: e.g. I have 3 user fixtures. But my development db, that I clone, contains like 30 users. After running a controller for example, I only have the 3 fixtures in the test db
[11:42:49] kidPalooma: has joined #RubyOnRails
[11:48:18] cpruitt: has joined #RubyOnRails
[11:49:00] fox_mulder_cp: test db cleared after test is ended
[11:55:06] ariedler: has joined #RubyOnRails
[12:10:21] NoGodDamnIdea: has joined #RubyOnRails
[12:17:58] blackmesa: has joined #RubyOnRails
[12:21:25] conta1: has joined #RubyOnRails
[12:49:54] alexhartley: has joined #RubyOnRails
[12:50:03] cpruitt: has joined #RubyOnRails
[12:50:13] skryking: has joined #RubyOnRails
[13:08:12] ariejan: has joined #RubyOnRails
[13:09:11] cpruitt: has joined #RubyOnRails
[13:19:21] cpruitt: has joined #RubyOnRails
[13:29:19] borodin: has joined #RubyOnRails
[13:41:13] Guest16678: has joined #RubyOnRails
[13:43:11] beholders_eye: has joined #RubyOnRails
[13:47:56] beholders_eye: has joined #RubyOnRails
[13:49:16] cpruitt: has joined #RubyOnRails
[13:50:31] chouhoulis: has joined #RubyOnRails
[14:00:07] Puffball: has joined #RubyOnRails
[14:12:21] cpruitt: has joined #RubyOnRails
[14:18:55] beholders_eye: has joined #RubyOnRails
[14:19:39] eclm: has joined #RubyOnRails
[14:46:55] Net: What do you think of setting Time.zone to the user’s time zone instead of UTC?
[14:50:02] beholders_eye: has joined #RubyOnRails
[14:50:44] _aeris_: hello #rails :)
[14:50:56] _aeris_: i have a question about rails route helper and js
[14:51:26] _aeris_: i have a react JS application, which call some rails API behind
[14:51:53] _aeris_: I need to pass the base url api, with a data-api="…" in the HTML page
[14:52:29] _aeris_: i have trouble when I need to point a :show route without :index one
[14:53:30] _aeris_: if I have a Foo :show and :index, i can use foos_path to have /foos/ on the JS, which will be used to generate the /foos/{id} in JS
[14:54:23] _aeris_: but if i haven't :index, foos_path doesn't exits, but foo_path is not usable without an ID, and so no way to obtain the base path for the JS :(
[14:56:46] someuser: has joined #RubyOnRails
[14:57:09] uksio: has joined #RubyOnRails
[15:03:02] IGnorAND: param is missing or the value is empty: customer <- is there a way to see the params which go in my test?
[15:03:19] IGnorAND: The controller works fine as I can perform the tasks with http
[15:06:01] IGnorAND: I think I need to add the Content-Type: application/json; charset=utf-8
[15:11:31] kapil____: has joined #RubyOnRails
[15:19:30] RiPuk: has joined #RubyOnRails
[15:22:33] pLaTo0n: has joined #RubyOnRails
[15:35:14] krawchyk: has joined #RubyOnRails
[15:39:09] Dbugger: has joined #RubyOnRails
[15:43:05] IGnorAND: Anyone know why I am getting missing params: https://gist.github.com/nuheluxulu/d9ad244687f45beacaaf6c691bb7bfe9#file-customers_spec-rb-L4
[15:46:55] fox_mulder_cp: IGnorAND: REQIRED params must be present. required != allowed :)
[15:47:52] fox_mulder_cp: btw - why you hardcode it in expect(json['first_name']).to eq('Learn Elm') ? use valid_attributes[:first_name]
[15:48:00] IGnorAND: @fox_mulder_cp did you see the console version
[15:48:28] IGnorAND: https://gist.github.com/nuheluxulu/d9ad244687f45beacaaf6c691bb7bfe9#file-console-L1
[15:49:08] fox_mulder_cp: IGnorAND: post json {customer: { ...fields here}}
[15:49:20] fox_mulder_cp: not plain {name: '', surname}
[15:49:49] fox_mulder_cp: customer fields in json must be included in customer: {} json object
[15:51:20] fox_mulder_cp: data='{"customer":{"name":"blabla", .. , .. }}'; curl -XPOST -H 'Content-Type:application/json' -sd "$data" ${url_base} ..
[15:54:15] blackmesa: hey mikecmpbll and fox_mulder_cp I didnt get that later ago. I was gone and cant scroll up anymore. It was about fixtures and the test db
[15:54:32] mikecmpbll: blackmesa : supply all the data your test needs in fixtures
[15:54:50] mikecmpbll: otherwise your tests aren't reproducable. why are you trying to use a mixture of external data and fixtures?
[15:55:07] mikecmpbll: or, don't use fixtures, and source the data some other way.
[15:55:12] IGnorAND: @fox_mulder_cp is there a way to see what the rspec environment sends to my server so I can see what's going wrong?
[15:56:15] fox_mulder_cp: IGnorAND: rspec sends only described data :)
[15:56:54] IGnorAND: And a good way to see what I described would be?
[15:57:06] status402: has joined #RubyOnRails
[15:59:19] IGnorAND: @fox_mulder_cp https://gist.github.com/nuheluxulu/d9ad244687f45beacaaf6c691bb7bfe9#file-diff_rspec-rb-L3 this gives a different error, but not sure if I made it better, that's why I'd like to see what rspec sends
[16:02:10] blackmesa: I am also working on a rails api at the moment. Also using 'curl -XPOST'. But I want send an image. I had no luck in sending the image in the body as byte array I think. Now I am using form-data to send the image "curl -X POST -F 'image=@/tmp/image.jpg'". it works fine. Would a data byte array be more reasonable for this?
[16:05:15] krawchyk: has joined #RubyOnRails
[16:07:07] IGnorAND: @blackmesa have you been able to send text?
[16:07:41] blackmesa: you mean through parameters or in the body of the curl?
[16:08:14] IGnorAND: blackmesa: through parameters
[16:08:25] IGnorAND: my 'curl' seems to work fine.
[16:08:32] IGnorAND: it's my rspec that seems to fail
[16:09:18] IGnorAND: blackmesa: https://gist.github.com/nuheluxulu/d9ad244687f45beacaaf6c691bb7bfe9#file-console-L1 <- https://httpie.org/ is my curl.
[16:10:00] IGnorAND: @blackmesa https://httpie.org/doc#file-upload-forms seems to upload files
[16:13:32] srinidhi: has joined #RubyOnRails
[16:14:16] blackmesa: Ive send files trough form-data with my request. its working. But my question was for byte array
[16:14:36] blackmesa: dont you need "-F" in front of the params?
[16:14:52] blackmesa: http post localhost:3000/api/v1/customers -F first_name='Foo'
[16:14:53] IGnorAND: aah, ok :) sorry can't help you. I seem to need to learn much more first :(
[16:15:16] IGnorAND: @blackmesa my http post works, so no need for the -F, its my rspec that breaks
[16:16:41] blackmesa: I think your params are not wrapped as a hash
[16:16:59] chouhoulis: has joined #RubyOnRails
[16:17:44] blackmesa: param is missing or the value is empty: customer
[16:18:22] blackmesa: needs to be like {customer: {first_name: 'test', last_name: 'xxx'}}
[16:18:26] IGnorAND: @blackmesa https://scotch.io/tutorials/build-a-restful-json-api-with-rails-5-part-one <- I made a new project and did this step by step, but this is API only, and this seems to work without the wrapping
[16:18:57] IGnorAND: @blackmesa I also tried it like that: https://gist.github.com/nuheluxulu/d9ad244687f45beacaaf6c691bb7bfe9#file-diff_rspec-rb-L6
[16:24:37] krawchyk: has joined #RubyOnRails
[16:31:46] orbyt_: has joined #RubyOnRails
[16:33:40] pLaTo0n: has joined #RubyOnRails
[16:34:39] srinidhi: has joined #RubyOnRails
[16:42:41] krawchyk: has joined #RubyOnRails
[16:52:35] conta1: has joined #RubyOnRails
[16:59:06] krawchyk: has joined #RubyOnRails
[17:11:16] duderonomy: has joined #RubyOnRails
[17:24:35] Guest16678: has joined #RubyOnRails
[17:25:26] gambl0r3: has joined #RubyOnRails
[17:42:00] Technodrome: has joined #RubyOnRails
[17:49:50] blackmesa: Hey. My views are pretty clogged with lots of .js.erb files partials, so that I could make a simple modal. The .js.erb files always called partials and so on. Is there a way around it? ive never used a js frontend
[17:50:46] srinidhi: has joined #RubyOnRails
[17:56:29] ariedler: has joined #RubyOnRails
[18:04:36] Saukk: has joined #RubyOnRails
[18:07:54] reber: has joined #RubyOnRails
[18:11:48] chouhoulis: has joined #RubyOnRails
[18:16:13] lexileo: has joined #RubyOnRails
[18:26:20] elcontrastador: has joined #RubyOnRails
[18:27:12] defsdoor: has joined #RubyOnRails
[18:40:41] IGnorAND: @blackmesa I am trying to switch to vuejs
[18:40:51] IGnorAND: makes it a lot better to oversee the code
[18:42:07] blackmesa: I was looking at it. do you use rails as backend with vuejs frontend?
[18:43:23] IGnorAND: @blackmesa that's what I am trying yeah. I have 1 project I'm trying to do as two seperate servers, and 1 where I'm trying to display the vuejs in the same rails server
[18:44:14] blackmesa: and you new to rails? you are already using rspec
[18:45:00] mikecmpbll: has joined #RubyOnRails
[18:45:09] IGnorAND: @blackmesa I wrote in it years ago, am trying to catch up again
[18:45:12] orbyt_: has joined #RubyOnRails
[18:45:36] IGnorAND: I'm thinking there is more value in creating solutions as a programmer
[18:45:40] blackmesa: cool. I am trying to get used to minitest
[18:49:02] IGnorAND: I havent used that
[19:11:02] duderonomy: has joined #RubyOnRails
[19:12:08] IGnorAND: @blackmesa so why did you pick minitest instead of the others?
[19:13:24] skryking: has joined #RubyOnRails
[19:15:28] ravenousmoose: has joined #RubyOnRails
[19:37:13] ravenousmoose: has joined #RubyOnRails
[19:44:15] conta1: has joined #RubyOnRails
[19:56:01] krawchyk: has joined #RubyOnRails
[19:57:19] ariedler: has joined #RubyOnRails
[20:03:12] tdy: has joined #RubyOnRails
[20:18:05] blackmesa: has joined #RubyOnRails
[20:30:52] orbyt_: has joined #RubyOnRails
[20:31:30] blackcross: has joined #RubyOnRails
[20:48:42] orbyt_: has joined #RubyOnRails
[20:55:10] liya: has joined #RubyOnRails
[20:55:21] ryandv: has joined #RubyOnRails
[20:55:29] blackmesa: hey sry. because its built in and for my purposes sufficient.
[20:55:42] ur5us: has joined #RubyOnRails
[20:56:23] ryandv: hi - is it possible to specify an array as a bind to `exec_query` for use in a `WHERE ... IN` statement? e.g. `ActiveRecord::Base.connection.exec_query('SELECT * FROM foos WHERE id IN ($1)', 'my_query_name', [ [nil, [1,2,3,4]] ])`
[20:56:42] ryandv: I explicitly do not want to use ApplicationRecords and instead want raw SQL
[20:56:46] ur5us: has joined #RubyOnRails
[21:02:41] krawchyk: has joined #RubyOnRails
[21:11:44] lxsameer: has joined #RubyOnRails
[21:18:01] blackmesa: has joined #RubyOnRails
[21:21:29] blackmesa: has joined #RubyOnRails
[21:58:11] ariedler: has joined #RubyOnRails
[22:11:38] brandoncc: has joined #RubyOnRails
[22:12:01] DoctorMonocular: has joined #RubyOnRails
[22:12:42] DoctorMonocular: I'm trying to do the normal pattern of method(thing_or_things); Array(thing_or_things).each... ; end;
[22:12:56] DoctorMonocular: but the thing in this case is already array-like
[22:13:09] DoctorMonocular: so when I pass a single one in like [1,2]
[22:13:20] DoctorMonocular: I want it to end up like [[1,2]]
[22:13:38] DoctorMonocular: which obviously doesn't work with Array()
[22:13:56] DoctorMonocular: what's my cleanest bet, without is_a?(Array) nonsense?
[22:14:03] baweaver: What's the actual code in question?
[22:14:07] baweaver: Splat, normally.
[22:14:20] baweaver: def one_or_many(*items) ... end
[22:15:14] DoctorMonocular: wouldn't that also fail in this case? if I pass [1,2] as the argument?
[22:16:15] DoctorMonocular: the items would be 1 and 2, instead of the items being a single value: [1,2]
[22:16:59] baweaver: What's the usecase?
[22:17:35] baweaver: because more than likely it would be an `is_a?` call
[22:18:08] DoctorMonocular: I have a class that organizes datetime ranges using certain logic, and this method accepts either a single range or an array of ranges to do some logic to
[22:18:09] baweaver: Though admittedly I find it kind of an anti-pattern to do so.
[22:18:39] DoctorMonocular: but I actually do a duck type check, so I can accept anything that responds to :first and :last
[22:19:12] baweaver: Could you make it into multiple methods?
[22:19:32] DoctorMonocular: but when I pass a single range in or any other single thing that responds to first and last, the Array() thing doesn't work for obvious reasons
[22:20:00] DoctorMonocular: eh. Yeah I guess. That might be cleanest
[22:20:03] baweaver: Have a code sample?
[22:20:14] baweaver: Depending on what it is there may be a way around it
[22:21:08] DoctorMonocular: I doubnt it's helpful, but here:
[22:21:08] DoctorMonocular: https://gist.github.com/PeteMichaud/d4d478618a7b332b7933a4e96eafddc8
[22:21:40] DoctorMonocular: block is canonically a range, but actually can be anything that responds to :first and :last, like I said
[22:25:04] baweaver: Yeah, I'd break it into `add_block` and `add_blocks` personally
[22:25:10] baweaver: too much conflating of logic otherwise.
[22:25:21] DoctorMonocular: ok, I think I'll do that
[22:25:26] baweaver: add_block can have the code
[22:25:33] baweaver: add_blocks can just call add_block for each element
[22:27:22] baweaver: DoctorMonocular: https://gist.github.com/PeteMichaud/d4d478618a7b332b7933a4e96eafddc8#gistcomment-2819362
[22:27:24] baweaver: pretty much that
[22:27:52] DoctorMonocular: that is exactly what I wrote, yeah
[22:40:01] uks: has joined #RubyOnRails
[23:10:27] creamme: has joined #RubyOnRails
[23:20:23] ariedler: has joined #RubyOnRails
[23:31:24] DoctorMonocular: ok, so I know this is a bad idea, but I want to know for future reference
[23:31:35] jheathco: has joined #RubyOnRails
[23:31:48] DoctorMonocular: say I want to allow arbitrary meta data to be added to any object
[23:32:05] jheathco: anyone know why in rails 5 doing a simple get '/story', to: 'home#story' would result in undefineid variable or method 'story_path' when using this in a simple view? it shows fine in rake routes
[23:32:17] DoctorMonocular: so I could monkeypatch Object with something like a meta hash instance variable
[23:32:22] DoctorMonocular: then be able to do like 1.meta
[23:32:42] DoctorMonocular: but what if I only want to enable meta data on a given object instance on purpose?
[23:33:02] DoctorMonocular: like 1.meta would blow up, but something like 1.with_meta.meta would work?
[23:33:31] DoctorMonocular: with_meta needs to be monkey patched into Object, but is it possible to inject the meta hash or whatever directly into the instance?