« Back to channel list

#RubyOnRails - 08 August 2018

Forward 1 day »
[05:56:20] helpa: has joined #RubyOnRails
[05:56:41] srinidhi: has joined #RubyOnRails
[05:57:49] moei: has joined #RubyOnRails
[05:58:20] DTZUZO: has joined #RubyOnRails
[05:59:48] Aherin: has joined #RubyOnRails
[06:03:08] alfiemax: has joined #RubyOnRails
[06:06:39] lexileo: has joined #RubyOnRails
[06:08:19] quazimodo: has joined #RubyOnRails
[06:08:21] snickers: has joined #RubyOnRails
[06:10:32] alfiemax: has joined #RubyOnRails
[06:13:12] eckhardt_: has joined #RubyOnRails
[06:13:16] apeiros_: has joined #RubyOnRails
[06:19:58] rrichardsr3: has joined #RubyOnRails
[06:27:00] lxsameer: has joined #RubyOnRails
[06:37:11] lxsameer: has joined #RubyOnRails
[06:41:28] apeiros_: has joined #RubyOnRails
[06:43:47] hfp_work: has joined #RubyOnRails
[06:46:13] webdestroya: has joined #RubyOnRails
[06:46:34] atrius: has joined #RubyOnRails
[06:46:56] orbyt_: has joined #RubyOnRails
[06:47:04] lxsameer: has joined #RubyOnRails
[06:53:54] dionysus69: has joined #RubyOnRails
[07:06:38] snickers: has joined #RubyOnRails
[07:07:13] Technodrome: has joined #RubyOnRails
[07:11:10] spohnz_: has joined #RubyOnRails
[07:20:04] kapil___: has joined #RubyOnRails
[07:24:03] desnudopenguino: has joined #RubyOnRails
[07:36:55] drale2k_: has joined #RubyOnRails
[07:46:28] Technodrome: has joined #RubyOnRails
[07:50:24] lxsameer: has joined #RubyOnRails
[08:03:42] mikecmpbll: has joined #RubyOnRails
[08:06:50] dionysus69: has joined #RubyOnRails
[08:16:29] _aeris_: has left #RubyOnRails: ("Konversation terminated!")
[08:21:21] desperek: has joined #RubyOnRails
[08:26:06] Dbugger: has joined #RubyOnRails
[08:40:25] quazimodo: has joined #RubyOnRails
[08:50:27] alfiemax: has joined #RubyOnRails
[08:59:19] rrichardsr3: has joined #RubyOnRails
[09:12:18] alfiemax_: has joined #RubyOnRails
[09:14:50] orbyt_: has joined #RubyOnRails
[09:15:20] DrYockel: has joined #RubyOnRails
[09:19:33] rrichard_: has joined #RubyOnRails
[09:45:30] lypsis: has joined #RubyOnRails
[10:01:03] drale2k_: has joined #RubyOnRails
[10:10:37] alfiemax: has joined #RubyOnRails
[10:38:38] Technodrome: has joined #RubyOnRails
[11:20:35] Technodrome: has joined #RubyOnRails
[11:23:44] blackmesa: has joined #RubyOnRails
[11:24:33] sunya7a: has joined #RubyOnRails
[11:45:37] dionysus69: I have event machine in a method that would call itself upon websocket close event, so basically I want to keep it running all the time, what's the best way to keep this kind of service running at all times? where do I start it?
[11:46:18] dionysus69: I am using faye/websocket gem
[11:58:27] blackmesa1: has joined #RubyOnRails
[12:19:47] ciro: has joined #RubyOnRails
[12:50:37] fmcgeough: has joined #RubyOnRails
[12:58:08] alfiemax_: has joined #RubyOnRails
[13:09:30] dionysus69: has joined #RubyOnRails
[13:09:35] darkhanb: has joined #RubyOnRails
[13:31:42] lexileo: has joined #RubyOnRails
[13:38:33] dionysus69: has joined #RubyOnRails
[13:43:57] uksio: has joined #RubyOnRails
[13:54:35] DTZUZO: has joined #RubyOnRails
[13:57:15] Hexafox[I]: has joined #RubyOnRails
[13:59:54] Technodrome: has joined #RubyOnRails
[14:00:07] HoierM: has joined #RubyOnRails
[14:16:55] lexileo: has joined #RubyOnRails
[14:21:01] greengriminal: has joined #RubyOnRails
[14:35:26] blackmesa1: has joined #RubyOnRails
[14:35:33] rrichardsr3: has joined #RubyOnRails
[14:40:00] Technodrome: has joined #RubyOnRails
[14:43:42] arefaslani: has joined #RubyOnRails
[14:49:46] arefaslani: Hi everybody! I want to create a RoR JSON API. JSON API errors format is something like this:
[14:49:47] arefaslani: https://gist.github.com/arefaslani/81a5fe231e6c5b90627bcd6f23eb946f#file-errors-json
[14:50:22] arefaslani: This is my users controller:
[14:50:23] arefaslani: https://gist.github.com/arefaslani/81a5fe231e6c5b90627bcd6f23eb946f#file-users_controller-rb
[14:51:06] arefaslani: My problem is that I cant fill the 'pointer' attribute of the response correct automatically.
[14:51:33] arefaslani: look at `e.param` in this line:
[14:51:33] arefaslani: https://gist.github.com/arefaslani/81a5fe231e6c5b90627bcd6f23eb946f#file-users_controller-rb-L10
[14:52:23] arefaslani: it's for example 'data' or 'attributes'. But what I want is '/data/attributes' or '/data/relationships/accounts'
[14:52:59] arefaslani: How can I get the error's source param with the ancestor params attached with it?
[14:53:19] dblessing: has joined #RubyOnRails
[14:56:24] akaiiro: has joined #RubyOnRails
[15:01:59] mojtaba: has joined #RubyOnRails
[15:02:29] mojtaba: Hello, I am using rails 5.1.6 and ruby 2.5.0.p0. Could you please let me know how should I update to the latest version of rails? (I am using Ubuntu 16.04 LTS)
[15:03:20] blackmesa1: has joined #RubyOnRails
[15:13:26] drale2k_: has joined #RubyOnRails
[15:15:43] Technodrome: has joined #RubyOnRails
[15:18:08] sarmiena_: has joined #RubyOnRails
[15:22:29] HoierM: has joined #RubyOnRails
[15:23:57] arefaslani: set rails version to 5.2.1 in the gemfile
[15:24:21] arefaslani: then run `rails app:update`
[15:24:30] mojtaba: arefaslani: How can I upgrade system wide?
[15:25:21] arefaslani: just install the latest version: gem install rails -v '5.2.1'
[15:28:24] mojtaba: arefaslani: thanks
[15:28:59] arefaslani: @mojtaba: Good luck ;)
[15:32:45] apeiros_: has joined #RubyOnRails
[15:33:08] chouhoulis: has joined #RubyOnRails
[15:53:01] Cache_Money: has joined #RubyOnRails
[15:58:34] apeiros_: has joined #RubyOnRails
[16:02:07] arefaslani: has joined #RubyOnRails
[16:02:44] drale2k_: i am using form_with to submit a form via ajax but for some reason it is not submitted with ajax, instead it follows the redirect resource
[16:03:04] HoierM: has joined #RubyOnRails
[16:03:04] drale2k_: looking at the HTML, the form has a data-remote=true attribute and everything else looks fine
[16:10:12] DTZUZO: has joined #RubyOnRails
[16:12:44] Axsuul: has joined #RubyOnRails
[16:20:00] ciro: has joined #RubyOnRails
[16:20:54] Technodrome: has joined #RubyOnRails
[16:25:30] orbyt_: has joined #RubyOnRails
[16:29:21] arefaslani: has joined #RubyOnRails
[16:43:29] akaiiro: has joined #RubyOnRails
[16:44:17] sarmiena_: has joined #RubyOnRails
[16:44:57] Inside: has joined #RubyOnRails
[16:45:06] Inside: Sad day. Gutting out about 10% of my application that's no longer used :'(
[16:47:12] lxsameer: has joined #RubyOnRails
[16:53:03] ciro: has joined #RubyOnRails
[16:56:29] za1b1tsu: has joined #RubyOnRails
[16:57:13] lxsameer: has joined #RubyOnRails
[16:58:53] hahuang65: hmmm why's that sad?
[17:06:19] arefaslani: has joined #RubyOnRails
[17:07:10] lxsameer: has joined #RubyOnRails
[17:16:50] [Butch]: has joined #RubyOnRails
[17:17:07] lxsameer: has joined #RubyOnRails
[17:18:29] arefaslani: has joined #RubyOnRails
[17:22:25] snickers: has joined #RubyOnRails
[17:22:32] arefaslani: has joined #RubyOnRails
[17:25:07] mikecmpbll: has joined #RubyOnRails
[17:27:04] lxsameer: has joined #RubyOnRails
[17:37:04] lxsameer: has joined #RubyOnRails
[17:37:20] prettybTech: has joined #RubyOnRails
[17:45:15] eckhardt_: has joined #RubyOnRails
[17:47:04] lxsameer: has joined #RubyOnRails
[17:55:01] dblessing: has joined #RubyOnRails
[17:55:05] sameerynho: has joined #RubyOnRails
[17:56:01] prettybTech: has joined #RubyOnRails
[17:57:05] lxsameer: has joined #RubyOnRails
[18:01:31] spohnz: has joined #RubyOnRails
[18:02:18] safetypin: has joined #RubyOnRails
[18:05:54] tomaw: has joined #RubyOnRails
[18:06:53] dionysus69: has joined #RubyOnRails
[18:07:03] lxsameer: has joined #RubyOnRails
[18:14:00] akaiiro: has joined #RubyOnRails
[18:17:05] lxsameer: has joined #RubyOnRails
[18:17:26] scrptktty: has joined #RubyOnRails
[18:17:46] snickers: has joined #RubyOnRails
[18:18:32] johndunn: has joined #RubyOnRails
[18:21:13] nzst: has joined #RubyOnRails
[18:27:04] lxsameer: has joined #RubyOnRails
[18:37:09] lxsameer: has joined #RubyOnRails
[18:40:17] HoierM: has joined #RubyOnRails
[18:47:11] lxsameer: has joined #RubyOnRails
[18:48:27] mojtaba: has joined #RubyOnRails
[18:50:07] Inside: hahuang65: it's a log of old work being thrown out
[18:50:15] Inside: what do you guys do w/ the migration files for old features?
[18:50:17] Inside: delete them?
[18:50:18] Inside: leave them there?
[18:57:13] lxsameer: has joined #RubyOnRails
[18:58:40] hahuang65: Inside: getting rid of old cruft is always a good thing IMO
[18:59:10] mroutis: has joined #RubyOnRails
[18:59:10] hahuang65: Inside: if you've got your code in version control, then delete them
[19:00:12] Aherin: has joined #RubyOnRails
[19:00:16] Inside: This is true
[19:01:39] sirensari2: has joined #RubyOnRails
[19:05:13] Aherin: has joined #RubyOnRails
[19:07:11] lxsameer: has joined #RubyOnRails
[19:10:03] rrichardsr3: has joined #RubyOnRails
[19:17:00] lxsameer: has joined #RubyOnRails
[19:17:21] Technodrome: has joined #RubyOnRails
[19:24:12] sarmiena_: has joined #RubyOnRails
[19:24:57] sarmiena_: has joined #RubyOnRails
[19:25:58] sarmiena_: has joined #RubyOnRails
[19:26:15] srinidhi: has joined #RubyOnRails
[19:26:54] mojtaba: has joined #RubyOnRails
[19:27:07] lxsameer: has joined #RubyOnRails
[19:27:30] sarmiena_: has joined #RubyOnRails
[19:27:44] alfiemax_: has joined #RubyOnRails
[19:28:20] sarmiena_: has joined #RubyOnRails
[19:34:58] Croata: has joined #RubyOnRails
[19:36:29] lupine: there are various surprising costs to having a huge number of files in db/migrate, from slow specs on
[19:37:02] lxsameer: has joined #RubyOnRails
[19:40:21] prettybTech: has joined #RubyOnRails
[19:42:17] lexileo: has joined #RubyOnRails
[19:46:51] beowuff: has joined #RubyOnRails
[19:46:54] hnanon: has joined #RubyOnRails
[19:47:04] lxsameer: has joined #RubyOnRails
[19:48:51] hnanon: I have a User model with a profile image attachment, attached via Paperclip. I newly create a Profile model and it now will have that image as an attribute (instead of the User having it). I also migrated to ActiveStorage.
[19:48:58] hnanon: New attachments work fine.
[19:49:19] hnanon: How can I migrate the older referenced images from the User table to the Profile table?
[19:49:50] za1b1tsu: has joined #RubyOnRails
[19:49:52] hnanon: I'm trying to follow this guide: https://github.com/thoughtbot/paperclip/blob/master/MIGRATING.md
[19:50:16] hnanon: However, that just migrates from the User table to the same User table.
[19:50:36] hnanon: I'm not sure how to adopt it to migrate to the Profile model.
[19:52:03] mojtaba: has joined #RubyOnRails
[19:53:57] snickers: has joined #RubyOnRails
[19:57:02] lxsameer: has joined #RubyOnRails
[19:57:43] Inside: old feature gone :'( 100 files, 2000 lines of ruby code[as reported by the 'coverage' gem], thousands more of templates..)
[20:01:13] Inside: you're moving from AS to PC?
[20:01:17] Inside: or from PC to AS?
[20:04:21] nzst: has joined #RubyOnRails
[20:07:06] lxsameer: has joined #RubyOnRails
[20:10:10] hnanon: Inside: from PC to AS.
[20:15:55] spohnz: has joined #RubyOnRails
[20:17:05] lxsameer: has joined #RubyOnRails
[20:22:39] mroutis: has joined #RubyOnRails
[20:26:44] s2013: has joined #RubyOnRails
[20:27:07] lxsameer: has joined #RubyOnRails
[20:34:54] SunWuKung: has joined #RubyOnRails
[20:37:08] lxsameer: has joined #RubyOnRails
[20:47:09] lxsameer: has joined #RubyOnRails
[20:48:22] blackmesa1: has joined #RubyOnRails
[20:48:47] dblessing: has joined #RubyOnRails
[20:58:39] Slogger: Is there a built in way to get information on enqueued but not yet performed active jobs?
[21:00:37] lupine: dunno about ActiveJob, but if it's just sat on top of sidekiq, you can definitely get it form thre
[21:00:40] lupine: from there*
[21:03:28] prettybTech: has joined #RubyOnRails
[21:16:00] prettybTech: has joined #RubyOnRails
[21:21:47] s2013: has joined #RubyOnRails
[21:31:49] za1b1tsu: has joined #RubyOnRails
[21:38:23] alfiemax: has joined #RubyOnRails
[21:40:33] spohnz: has joined #RubyOnRails
[21:42:09] lxsameer: has joined #RubyOnRails
[21:42:51] spohnz: has joined #RubyOnRails
[21:47:10] lxsameer: has joined #RubyOnRails
[22:03:23] prettybTech: has joined #RubyOnRails
[22:06:55] spohnz: has joined #RubyOnRails
[22:09:30] spohnz: has joined #RubyOnRails
[22:11:49] spohnz: has joined #RubyOnRails
[22:19:03] Radar: GOOD MORNING
[22:19:25] Radar: Slogger: Sidekiq has a web interface which can tell you that information (if you're using sidekiq)
[22:21:03] Radar: From a cursory look through AJ's code it doesn't look like it's possible to get a number out from it directly.
[22:21:56] Radar: README doesn't indicate that it's a feature either.
[22:22:56] lupine: yay abstractions
[22:27:00] lxsameer: has joined #RubyOnRails
[22:32:41] hahuang65: hmm is there a way, with Enumerator, to iterate on chunks of the set?
[22:32:59] hahuang65: i.e. instead of Enumerator.each do |item|, Enumerator.each(100) do |items|
[22:34:15] za1b1tsu: has joined #RubyOnRails
[22:37:02] lxsameer: has joined #RubyOnRails
[22:41:31] arooni_team_b: has joined #RubyOnRails
[22:43:47] sariyar: has joined #RubyOnRails
[22:47:05] Radar: hahuang65: each_slice(n)
[22:47:52] hahuang65: Radar: dammit.
[22:48:39] hahuang65: Radar: I started working with just .each and grouping them by hand. then I saw your reply lol
[22:49:58] Radar: hahuang65: I think Elixir's called theirs the same as well ;)
[22:50:04] Radar: The Enumerable module provides lots of helpful stuff.
[22:53:36] hahuang65: Radar: oddly, I was looking thru the Ruby Enumerable docs, and I didn't see each_slice. Maybe my eyes are broken.
[22:53:37] Xiti`: has joined #RubyOnRails
[22:55:25] creature: has joined #RubyOnRails
[22:57:50] creature: Hi folks. I'm currently upgrading an old Rails app to Rails 4.2. The DB backend is Postgres, which supports JSON as a field type. One of the (very welcome!) changes in this migration is that before, ActiveRecord would return these fields as strings, but now they come back as Ruby hashes. And generally, you can just treat them as hashes now.
[22:59:22] creature: But I'm having trouble with one part of this migration. There's a place where the frontend sends a string containing JSON to the backend. It's got a couple of levels of nesting in it. I need to query for a matching record in the DB, and I'm having trouble getting that to work. Is there a recommended way of tackling this?
[23:00:38] creature: Passing the string as `Foo.where(bar: params[:bar])` isn't returning me any results. `Foo.where(bar: JSON.parse(params[:bar]))` gives me an SQL syntax error, apparently because it's getting reserialised as YAML somewhere.
[23:00:40] fumk: has joined #RubyOnRails
[23:01:02] hahuang65: creature: what's params[:bar] look like?
[23:01:38] fl4sh__: has joined #RubyOnRails
[23:01:48] Slogger: creature: worst case you could use raw SQL with postgres syntax.
[23:01:57] creature: Passing the string as `Foo.where(bar: params[:bar])` isn't returning me any results. `Foo.where(bar: JSON.parse(params[:bar]))` gives me an SQL syntax error, apparently because it's getting reserialised as YAML somewhere.
[23:02:02] creature: Whoops, sorry,
[23:02:09] creature: params[:bar] is the string-containing-JSON.
[23:02:36] creature: It's got some nested "hashes" and arrays in it.
[23:03:02] creature: (Hashes in quotes because JavaScript would call it an object literal, but it's a Hash when deserialised in the Ruby world.)
[23:03:11] syndikate: has joined #RubyOnRails
[23:03:34] armyriad: has joined #RubyOnRails
[23:03:44] hahuang65: creature: can you show us an example of params[:bar]?
[23:04:09] LightStalker: has joined #RubyOnRails
[23:04:11] xhoy: has joined #RubyOnRails
[23:04:19] creature: Not without having to redact a lot of details, but I can answer some questions about its shape. :) Sorry, I know that's a pain.
[23:04:50] creature: It's about 1800 characters long. Chunky, but not unmanagable.
[23:06:07] Caerus: has joined #RubyOnRails
[23:06:19] Exagone313: has joined #RubyOnRails
[23:07:32] segy: has joined #RubyOnRails
[23:08:12] hahuang65: creature: it's hard to say without seeing the details. I would have expected JSON.parse to work.
[23:09:44] Cyrus: has joined #RubyOnRails
[23:09:57] s2013: has joined #RubyOnRails
[23:10:34] creature: hahuang65: I can parse it fine with JSON.parse, that gives me a Ruby hash back. The problem is how to query for a record with a matching JSON field.
[23:11:29] creature: As in, "find a record from the DB where its JSON field matches the Ruby object I have in my controller". Where the Ruby object is from parsing params[:bar].
[23:11:41] Radar: Definitely hard without seeing the details.
[23:12:40] ChanServ: +o baweaver
[23:12:58] ChanServ: -o baweaver
[23:13:54] ivanskie: has joined #RubyOnRails
[23:14:16] baweaver: 5.2.1 dropped today
[23:14:29] creature: Sorry, BRB, fire alarm in this building. :(
[23:17:08] lxsameer: has joined #RubyOnRails
[23:20:56] cschneid_: has joined #RubyOnRails
[23:22:05] lxsameer: has joined #RubyOnRails
[23:31:37] creature: Back. No fire.
[23:32:14] lxsameer: has joined #RubyOnRails
[23:32:32] s2013: has joined #RubyOnRails
[23:33:58] Radar: creature: ok, let's resume. Show us the Ruby object in your controller and the structure of the JSON in your database please.
[23:34:10] Radar: I'm about to step away for a few meetings, but perhaps hahuang65 or baweaver could help you?
[23:34:15] creature: Anyway, yes, I know it's tricky to debug without the exact data, but hopefully we can consider this an ActiveRecord question. I'm presuming that I can't rely on querying this JSON field with a string value, as I _think_ JSON doesn't guarantee ordering for objects? Like, `{"a": 1, "b": 2}` is considered equal to `{"b": 2, "a": 1}`. So even if I did an SQL query for strings, it seems like this would be pretty brittle.
[23:34:37] creature: Like, I'd be relying on the frontend generating the same key ordering as Postgres, and that seems... risky.
[23:35:20] Hexafox[I]: has joined #RubyOnRails
[23:35:22] Radar: It's a JSON field within a Postgres database. You should probably be using the json querying things built in to postgres
[23:35:30] Radar: assuming that it's stored as the json/jsonb type and not "string"
[23:35:47] creature: It's a JSON type in the DB, yep.
[23:36:15] creature: I know about some of the Postgres operators, and I've found some good articles about querying based on them. But this one's a bit more... literal.
[23:36:40] baweaver: ACTION is trying to get context
[23:36:51] creature: As in, I'm not trying to do "Get all records with a key of 'foo'" or "Get all records that have at least 2 elements in array 'bar'". I'm just trying to find something which has the exact same object.
[23:37:28] Cache_Money: has joined #RubyOnRails
[23:39:06] felix_vs: has joined #RubyOnRails
[23:40:57] creature: Sigh, OK, I think that a big part of my problem here is not checking my assumptions. There's a lot of JSON/JSONB fields in this database... but I re-checked the schema here, and this one is text. :( I'm sorry for the wild goose chase, and I appreciate the debugging thoughts.
[23:42:12] baweaver: https://johnmosesman.com/post/querying-postgres-json-columns-with-activerecord/
[23:42:40] baweaver: https://www.postgresql.org/docs/9.6/static/functions-json.html
[23:42:54] baweaver: It looks like you're not going to get a nice magical nested hash for this
[23:43:31] Radar: creature: yeah well that's your first problem then. Convert it to json so it's at least queryable.
[23:43:42] Radar: creature: and yes, order does not matter in json objects OR Ruby hashes
[23:44:29] creature: Radar: I think you're mistaken on the latter half of that? https://github.com/rubocop-hq/ruby-style-guide#ordered-hashes
[23:45:35] baweaver: Na, he's right.
[23:45:49] baweaver: Equality won't care about that. It queries based on key
[23:45:55] Radar: {a: "b", b: "c"} == {b: "c", a: "b"}
[23:46:07] Radar: Ok, meeting time.
[23:46:08] creature: Right, yes, that makes sense.
[23:46:13] creature: Thanks again for the help! :)