creature

Activity Graph

Page 1 of 6 | Next »

2019-04-05

[22:01:17] creature: Ping timeout: 255 seconds

2019-03-18

[22:40:49] creature: Ping timeout: 255 seconds

2019-03-17

[04:57:35] creature: has joined #RubyOnRails

2019-03-16

[17:50:27] creature: Ping timeout: 240 seconds

2019-03-14

[02:14:36] creature: has joined #RubyOnRails

2019-02-26

[00:34:07] creature: Ping timeout: 240 seconds

2019-02-18

[21:31:15] creature: has joined #RubyOnRails

2018-08-14

[00:20:57] creature: Ping timeout: 240 seconds

2018-08-08

[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: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: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: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:14:29] creature: Sorry, BRB, fire alarm in this building. :(
[23:31:37] creature: Back. No fire.
[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: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: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: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: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:46:08] creature: Right, yes, that makes sense.
[23:46:13] creature: Thanks again for the help! :)

2018-05-23

[00:26:14] creature: Ping timeout: 276 seconds

2018-05-22

[01:55:07] creature: mices: Presuming you'd want that on every page, you could put it in app/views/layouts/application.html.erb.

2018-05-19

[18:31:09] creature: has joined #RubyOnRails

2018-05-17

[00:02:45] creature: Ping timeout: 264 seconds

2018-04-28

[23:43:50] creature: has joined #RubyOnRails

2018-03-06

[05:24:33] creature: Ping timeout: 240 seconds

2018-03-03

[15:19:20] creature: has joined #RubyOnRails

2018-03-02

[00:37:27] creature: Ping timeout: 240 seconds

2018-03-01

[05:44:45] creature: has joined #RubyOnRails

2018-02-22

[03:02:22] creature: Ping timeout: 268 seconds

2018-01-27

[02:49:25] creature: has joined #RubyOnRails

2018-01-26

[08:53:35] creature: Ping timeout: 260 seconds
[17:04:28] creature: has joined ##new2ruby
[17:04:28] creature: Changing host
[17:04:28] creature: has joined ##new2ruby

2018-01-15

[03:50:30] creature: has joined ##new2ruby
[03:50:30] creature: Changing host
[03:50:30] creature: Ping timeout: 265 seconds

2018-01-11

[01:54:27] creature: has joined #RubyOnRails

2018-01-09

[04:20:12] creature: Ping timeout: 246 seconds
[12:02:18] creature: has joined ##new2ruby
[12:02:18] creature: Changing host
[12:02:18] creature: has joined ##new2ruby

2018-01-08

[22:21:35] creature: Ping timeout: 240 seconds
[22:21:36] creature: has joined ##new2ruby
[22:21:36] creature: Changing host

2018-01-06

[23:54:39] creature: Ping timeout: 248 seconds
[23:54:40] creature: has joined ##new2ruby
[23:54:40] creature: Changing host

2018-01-05

[04:48:31] creature: Ping timeout: 248 seconds
[04:50:30] creature: has joined ##new2ruby
[04:50:30] creature: Changing host
[04:50:30] creature: has joined ##new2ruby
[06:26:05] creature: Ping timeout: 240 seconds
[06:26:06] creature: has joined ##new2ruby
[06:26:06] creature: Changing host
[06:34:39] creature: Ping timeout: 248 seconds
[06:36:45] creature: has joined ##new2ruby
[06:36:45] creature: Changing host
[06:36:45] creature: has joined ##new2ruby
[06:43:57] creature: Changing host
[06:43:57] creature: Ping timeout: 240 seconds
[06:43:58] creature: has joined ##new2ruby
[07:08:35] creature: Ping timeout: 240 seconds
[07:08:36] creature: has joined ##new2ruby
[07:08:36] creature: Changing host
[16:50:45] creature: has joined ##new2ruby
[16:50:45] creature: Changing host
[16:50:45] creature: Ping timeout: 264 seconds
[21:09:57] creature: has joined ##new2ruby
[21:09:57] creature: Changing host
[21:09:57] creature: Ping timeout: 263 seconds
[22:42:58] creature: Ping timeout: 268 seconds
[22:42:59] creature: has joined ##new2ruby
[22:42:59] creature: Changing host
[22:51:11] creature: Ping timeout: 248 seconds
[22:51:12] creature: has joined ##new2ruby
[22:51:12] creature: Changing host

2018-01-04

[03:24:29] creature: has joined ##new2ruby
[03:24:29] creature: Changing host
[03:24:29] creature: Ping timeout: 256 seconds
[04:07:27] creature: Ping timeout: 240 seconds
[04:07:28] creature: has joined ##new2ruby
[04:07:28] creature: Changing host
[04:26:39] creature: Ping timeout: 248 seconds
[04:26:40] creature: has joined ##new2ruby
[04:26:40] creature: Changing host
[19:01:27] creature: Ping timeout: 240 seconds
[19:01:28] creature: has joined ##new2ruby
[19:01:28] creature: Changing host
[23:30:31] creature: Ping timeout: 255 seconds
[23:30:32] creature: has joined ##new2ruby
[23:30:32] creature: Changing host
[23:37:57] creature: Ping timeout: 240 seconds
[23:40:14] creature: has joined ##new2ruby
[23:40:14] creature: Changing host
[23:40:14] creature: has joined ##new2ruby

2018-01-01

[04:19:13] creature: Changing host
[04:19:13] creature: Ping timeout: 248 seconds
[04:19:14] creature: has joined ##new2ruby
[04:25:37] creature: has joined ##new2ruby
[04:25:37] creature: Changing host
[04:25:37] creature: Ping timeout: 248 seconds
[04:33:44] creature: has joined ##new2ruby
[04:33:44] creature: Changing host
[04:33:44] creature: Ping timeout: 272 seconds
[05:01:36] creature: Ping timeout: 272 seconds
[05:01:37] creature: has joined ##new2ruby
[05:01:37] creature: Changing host
[05:14:39] creature: Ping timeout: 248 seconds
[05:14:40] creature: has joined ##new2ruby
[05:14:40] creature: Changing host
[06:12:48] creature: has joined ##new2ruby
[06:12:48] creature: Changing host
[06:12:48] creature: Ping timeout: 248 seconds
[06:26:09] creature: Ping timeout: 264 seconds
[06:27:58] creature: has joined ##new2ruby
[06:27:58] creature: Changing host
[06:27:58] creature: has joined ##new2ruby
[19:05:09] creature: has joined ##new2ruby
[19:05:09] creature: Changing host
[19:05:09] creature: Ping timeout: 264 seconds
[21:50:09] creature: Ping timeout: 264 seconds
[21:51:53] creature: has joined ##new2ruby
[21:51:53] creature: Changing host
[21:51:53] creature: has joined ##new2ruby
[21:56:40] creature: has joined #RubyOnRails
[22:03:36] creature: Ping timeout: 260 seconds
[22:05:14] creature: has joined ##new2ruby
[22:05:14] creature: Changing host
[22:05:14] creature: has joined ##new2ruby
[22:07:33] creature: has joined #RubyOnRails

2017-12-31

[00:08:57] creature: Ping timeout: 240 seconds
[00:08:58] creature: has joined ##new2ruby
[00:08:58] creature: Changing host

2017-12-29

[21:57:17] creature: has joined ##new2ruby
[21:57:17] creature: Changing host

2017-12-28

[05:36:39] creature: Ping timeout: 256 seconds
[11:37:33] creature: has joined ##new2ruby
[11:37:34] creature: has joined ##new2ruby
[11:37:34] creature: Changing host
[20:51:11] creature: Ping timeout: 248 seconds

2017-12-19

[00:58:49] creature: has joined #RubyOnRails

2017-12-18

[07:19:09] creature: has joined ##new2ruby
[07:19:09] creature: Changing host
[07:19:09] creature: Ping timeout: 265 seconds
[19:55:05] creature: has joined ##new2ruby
[19:55:05] creature: Changing host
[19:55:05] creature: Ping timeout: 265 seconds
[20:12:42] creature: Ping timeout: 272 seconds
[20:12:43] creature: has joined ##new2ruby
[20:12:43] creature: Changing host
[20:20:15] creature: Ping timeout: 248 seconds
[20:20:16] creature: has joined ##new2ruby
[20:20:16] creature: Changing host
[20:33:16] creature: has joined ##new2ruby
[20:33:16] creature: Changing host
[20:33:16] creature: Ping timeout: 265 seconds
[21:07:35] creature: has joined ##new2ruby
[21:07:35] creature: Changing host
[21:07:35] creature: Ping timeout: 240 seconds
[21:16:37] creature: Ping timeout: 256 seconds
[23:23:08] creature: has joined ##new2ruby
[23:23:08] creature: Changing host
[23:23:08] creature: has joined ##new2ruby

2017-12-15

[19:27:30] creature: Ping timeout: 265 seconds
[19:27:31] creature: has joined ##new2ruby
[19:27:31] creature: Changing host
[22:03:11] creature: Ping timeout: 248 seconds
[22:03:12] creature: has joined ##new2ruby
[22:03:12] creature: Changing host
[22:44:45] creature: has joined ##new2ruby
[22:44:45] creature: Changing host
[22:44:45] creature: Ping timeout: 264 seconds

2017-12-14

[07:15:29] creature: Ping timeout: 268 seconds
[17:22:19] creature: has joined ##new2ruby
[17:22:19] creature: Changing host
[17:22:19] creature: has joined ##new2ruby
[18:22:55] creature: has joined #RubyOnRails
[22:48:20] creature: has joined ##new2ruby
[22:48:20] creature: Changing host
[22:48:20] creature: Ping timeout: 272 seconds

2017-12-08

[16:28:38] creature: KeyJoo: Congrats! So it's all working?
[16:31:11] creature: I work as a web developer, so I'm pretty OK at Ruby. :) But there's always more to learn!
[16:35:50] creature: It's definitely possible, but hard work. I've personally seen plenty of people go through a coding bootcamp in 3 months, and come out as competent junior developers. And there are shorter bootcamps too, some as short as 2 months. I have less direct experience of those though.
[16:36:12] creature: So, 6 months is definitely doable. :)
[16:44:37] creature: I think the most important thing is to keep practicing and doing a little every day. Like, 30 minutes every day is going to be better than 5 hours once a week.

2017-12-07

[21:14:25] creature: KeyJoo: Do you have a broader example? You can add a code snippet at https://gist.github.com/ and then link it here.

2017-12-04

[21:38:00] creature: Cyrus: You can use the `read_attribute` method to do that, but overall my advice would be "don't have scopes with the same name as your attributes".

2017-12-01

[02:28:25] creature: has joined ##new2ruby

2017-11-21

[23:24:01] creature: hnanon: What have you tried so far? What's the hardest part of this?
[23:25:33] creature: Could you, for instance, manage to get just the market names listed out? How would you go about doing that? (You might find the 'getting started' guide & other docs at http://guides.rubyonrails.org/ useful).
[23:32:42] creature: hnanon: I think I'd expect that join to do what you'd expect it to. Do you have same raw sample data you could share, and the result of that query?
[23:42:02] creature: Yeah, I saw that. I'm not sure if you're approaching it all wrong.
[23:42:32] creature: It'd be useful to be able to see some example data, and the output you're getting from that query, and to compare it to what you've got in the sample.html.
[23:42:59] creature: Like, I'm presuming this is kind of a homeworky problem, and such a data dump would be easy to include in a gist. :) But I might be off-base there...
[23:47:50] creature: OK. Are you sure that this data is wrong? You're grouping by locations.market_id, not location_id.

2017-11-13

[15:48:49] creature: marahin: It looks like `response` isn't set, according to that error. I'm taking a complete shot in the dark as to the cause, but: does RSpec know that your test is a controller test? If not, it might not make a `response` object available.
[15:49:17] creature: So I think you should be able to do `describe 'People API', type: :controller` to "force" it, or make sure it's under spec/controllers.
[15:52:43] creature: Nice! I'm glad you got it working. :)
[16:26:12] creature: marahin: No idea there, I'm afraid. I've never used rswag.
[21:46:32] creature: "Stack" is a pretty common term.
[21:49:56] creature: Do you have different setups for production and staging?
[21:52:04] creature: Because I'd say your stack is "Resque, Redis, the DB, Rails, and Angular", and then you have "a staging environment" and "a production environment". Which each have their own instances of that stack.
[21:57:44] creature: I wouldn't worry too much about making it all fit neatly into a Venn diagram, personally.
[21:58:29] creature: I'd say "You have a Resque/Redis/DB/Rails/Angular stack, with separate production and staging environments, and you use Jenkins to promote builds from staging to production."

2017-11-08

[00:55:27] creature: Ping timeout: 240 seconds
[00:55:40] creature: has joined ##new2ruby
[00:55:40] creature: Changing host
[00:55:40] creature: has joined ##new2ruby
[03:05:33] creature: has joined #RubyOnRails

2017-10-26

[03:21:32] creature: enmchs: Hi!
[03:22:01] creature: Not much! How are you tonight?
[15:34:36] creature: Lucy_RF: I haven't used it, I'm afraid. Hopefully someone else here has. :)
[15:41:07] creature: I'm sorry to hear that, but glad you got a useful answer. :)
[15:41:39] creature: We're also a quiet channel, but I'm sure people who lurk here would be happy to help out if you have any other Ruby questions.

2017-10-20

[16:18:23] creature: has joined #RubyOnRails

2017-10-01

[01:42:28] creature: has joined ##new2ruby
[01:42:28] creature: Changing host
[01:42:28] creature: has joined ##new2ruby
[18:25:38] creature: has joined #RubyOnRails

2017-09-30

[17:40:02] creature: Ping timeout: 260 seconds

2017-09-28

[18:27:44] creature: has joined ##new2ruby
[18:27:44] creature: Changing host

2017-09-27

[04:29:52] creature: *.net *.split

2017-09-12

[15:53:59] creature: has joined #RubyOnRails

2017-09-07

[23:59:49] creature: has joined ##new2ruby
[23:59:49] creature: Changing host
[23:59:49] creature: has joined ##new2ruby

2017-09-03

[12:02:35] creature: Ping timeout: 240 seconds

2017-08-29

[02:10:21] creature: Ping timeout: 240 seconds
[02:12:32] creature: has joined ##new2ruby
[02:12:32] creature: Changing host
[02:12:32] creature: has joined ##new2ruby

2017-08-28

[21:06:15] creature: But the convention in Ruby is to name methods that return booleans such that they end with a ?.
[21:09:33] creature: FrostCandy: Correct.