zmo

Activity Graph

Page 1 of 2 | Next »

2019-05-27

[00:15:20] zmo: Ping timeout: 272 seconds
[03:17:45] zmo: has joined #RubyOnRails
[03:24:25] zmo: Ping timeout: 258 seconds
[03:29:59] zmo: has joined #RubyOnRails
[03:34:19] zmo: Ping timeout: 258 seconds
[03:40:33] zmo: has joined #RubyOnRails
[03:51:18] zmo: Ping timeout: 272 seconds
[04:36:45] zmo: has joined #RubyOnRails
[04:50:12] zmo: Ping timeout: 272 seconds
[07:07:41] zmo: has joined #RubyOnRails
[07:27:28] zmo: Ping timeout: 248 seconds
[07:59:28] zmo: has joined #RubyOnRails
[08:12:13] zmo: Ping timeout: 244 seconds
[12:55:56] zmo: has joined #RubyOnRails
[12:58:27] zmo: Remote host closed the connection
[13:00:57] zmo: has joined #RubyOnRails
[13:15:12] zmo: Ping timeout: 248 seconds
[13:48:29] zmo: has joined #RubyOnRails
[13:58:52] zmo: Remote host closed the connection

2019-05-26

[08:29:50] zmo: Ping timeout: 244 seconds
[08:46:16] zmo: has joined #RubyOnRails
[08:55:53] zmo: Remote host closed the connection
[09:01:27] zmo: has joined #RubyOnRails
[09:03:30] zmo: Remote host closed the connection
[10:32:56] zmo: has joined #RubyOnRails
[10:36:54] zmo: Remote host closed the connection
[10:47:19] zmo: has joined #RubyOnRails
[10:48:53] zmo: Remote host closed the connection
[12:22:31] zmo: has joined #RubyOnRails
[12:27:34] zmo: Ping timeout: 268 seconds
[12:48:17] zmo: has joined #RubyOnRails
[12:51:39] zmo: Remote host closed the connection
[13:04:10] zmo: has joined #RubyOnRails
[13:11:18] zmo: Remote host closed the connection
[13:18:02] zmo: has joined #RubyOnRails
[13:26:57] zmo: Remote host closed the connection
[13:55:23] zmo: has joined #RubyOnRails
[14:06:50] zmo: Remote host closed the connection
[14:33:44] zmo: has joined #RubyOnRails
[14:42:57] zmo: Remote host closed the connection
[15:23:06] zmo: has joined #RubyOnRails
[15:53:04] zmo: Ping timeout: 246 seconds
[16:27:58] zmo: has joined #RubyOnRails
[16:47:34] zmo: Ping timeout: 272 seconds
[17:34:28] zmo: has joined #RubyOnRails
[17:51:48] zmo: Ping timeout: 252 seconds
[20:52:21] zmo: has joined #RubyOnRails
[21:03:48] zmo: Ping timeout: 245 seconds
[23:14:22] zmo: has joined #RubyOnRails
[23:29:36] zmo: Ping timeout: 248 seconds
[23:59:27] zmo: has joined #RubyOnRails

2019-05-05

[12:36:23] zmo: hi 👋 I got a special need for TDD using VCR: I'm building a bunch of model instances with my factories, I then push those instances (using their ids) to an external service using a POST request, and then that service does its magic (which takes time), and returns me useful output using the pushed Ids through a GET request. My issue is that when I record the first time around, it stores the ids of the
[12:36:25] zmo: data from the POST, and when I do the GET it returns me the old models IDs. I'm looking for some documentation that would tell me how I can use ERB in the VCR cassette to refer the pushed IDs in the first request so I can give it back in the second
[12:36:59] zmo: and I'm trying googling and looking up on SO, but no luck trying to find the right question…
[12:37:07] zmo: (and I'm looking at the VCR docs too)
[13:37:05] zmo: or as an alternative, I thought I could stub the UUID generation of activerecord so values generated are predictable (using some generator). It's easy to stub SecureRandom, but still not finding how to stub activerecord's (which I guess does nothing and rely on postgresql's uuid function)
[16:12:43] zmo: ok, found the quick and dirty solution that works for me : I'm stubbing AR new/create and merge id with a stubbed SecureRandom uuid that generates UUID in sequence

2018-11-19

[22:40:17] zmo: Ping timeout: 268 seconds

2018-11-07

[08:17:58] zmo: Ping timeout: 245 seconds
[08:34:12] zmo: has joined #RubyOnRails

2018-09-11

[07:41:28] zmo: Ping timeout: 246 seconds
[08:20:47] zmo: has joined #RubyOnRails

2018-09-05

[04:38:57] zmo: Ping timeout: 240 seconds
[04:40:29] zmo: has joined #RubyOnRails

2018-07-31

[11:53:40] zmo: I'm writing tests for a controller using rspec, and I'm trying to check the content of a response. I get `expect(response).to render_template("new")` but when I do `expect(response).to have_content("sh!t that should be there")` it fails
[11:54:04] zmo: so I'd like to introspect the HTML that has been rendered, but I don't find what method gives that to me
[11:54:35] zmo: anybody could tell me or give me a good RTFM on how to debug using a response ?
[12:01:15] zmo: hm… I found response.body, but it's ""
[12:01:30] zmo: when I try with a web browser I actually get a page
[12:17:01] zmo: or, is there a way I can test the instance variables I setup in the controller that I give to the view ?
[12:17:27] zmo: I found I could do : `controller.instance_variable_get(:@that_variable)`
[12:17:29] zmo: and it works
[12:17:34] zmo: but it feels dirty
[12:20:52] zmo: TvL2386 - yeah, is there a _clean_ way I can try asserts on the controller's instance variables?
[12:24:58] zmo: well, I went that way because I don't get why I got no data from the response's body
[12:25:15] zmo: even though the controller's method actually works 🤔
[12:30:31] zmo: thank you
[12:30:51] zmo: I got to run for an hour, but I'll check back here when I come back ;)
[17:51:27] zmo: @TvL2386 - yaay \o/
[17:51:31] zmo: @TvL2386 - thank you so much
[17:51:46] zmo: how weird it's not much really visible in the documentation

2018-07-30

[13:33:09] zmo: hi there o/
[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: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: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: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:47] zmo: so technically `.select { |u| ... }` is that something ?
[13:45:38] zmo: yup, I know that `.select` is not part of SQL
[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: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:45] zmo: now my precise use case that makes it impossible to use `where.not()`
[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: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: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: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 :)
[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 ☺

2018-07-20

[00:07:07] zmo: *.net *.split
[00:15:27] zmo: has joined #RubyOnRails
[08:54:22] zmo: Ping timeout: 245 seconds
[09:12:08] zmo: has joined #RubyOnRails

2018-07-03

[09:53:09] zmo: Ping timeout: 264 seconds
[09:58:15] zmo: has joined #RubyOnRails

2018-06-29

[06:48:35] zmo: Ping timeout: 245 seconds
[06:52:20] zmo: has joined #RubyOnRails

2018-06-27

[07:45:51] zmo: Ping timeout: 240 seconds
[07:49:31] zmo: has joined #RubyOnRails

2018-06-26

[11:48:16] zmo: Ping timeout: 256 seconds
[11:50:27] zmo: has joined #RubyOnRails
[22:36:48] zmo: I've got in my project a whole subdir `app/models/users/user.rb` with STI that contains user variants: `app/models/users/admin.rb` or `app/models/users/operator.rb` where `class User < ActiveRecord::Base` and e.g. `class Admin < User`
[22:37:44] zmo: I tried to replicate just that with a class hierarchy `app/models/cats/cat.rb` and `app/models/cats/crazy_cat.rb`, `app/models/cats/lazy_cats.rb`
[22:37:55] zmo: s/lazy_cats/lazy_cat/
[22:38:41] zmo: but it does not work
[22:39:32] zmo: so however I tried to look, I don't see a difference between the user class hierarchy and the cat one, and I don't get why it works for the former, but not for the later.
[22:40:49] zmo: and by 'not working' I mean that in the console or the migrations I get `NameError: undefined constant CrazyCat` (but I can load `Cat`)
[22:42:29] zmo: if I do Cats::Cats in the console, then I get: `LoadError (Unable to autoload constant Cats::Cat expected to have app/models/cats/cat.rb to define it`
[22:42:41] zmo: Cats::Cat*
[22:42:46] zmo: and then I got Cat
[22:43:10] zmo: that's weird
[22:46:03] zmo: then how come it just works with users/user.rb being available as User and not Users::User
[22:47:15] zmo: well, that's that piece of the puzzle I'm trying to look for… I mean actually that's what I try to understant
[22:47:19] zmo: understand*
[22:49:16] zmo: I'm installing it
[22:51:10] zmo: apeiros - how can I use pry with the rails console ?
[22:53:51] zmo: ok thanks
[23:01:53] zmo: uh… not sure why, but it's still stuck with irb even though I installed pry-rails
[23:01:59] zmo: but anyway, that's not my main worry
[23:04:54] zmo: maybe it's the path name…
[23:05:37] zmo: apeiros - would run_steps/run_step.rb that contains class RunStep cause a worry?
[23:06:31] zmo: found it
[23:06:47] zmo: the users and others are being added in the auto_load_path in the config/
[23:06:56] zmo: ACTION bangs head on the keyboard

2018-06-15

[07:30:22] zmo: Ping timeout: 264 seconds
[08:50:38] zmo: has joined #RubyOnRails
[09:14:02] zmo: could anybody give me a hint/RTFM/pointer on the following issue: I have refactored a Model that I split into two Models by extracting a few values from the original model into the new one (through a one to many relation). To keep backward compatibility, I created a few methods on the original class that forwards to the new class's member
[09:16:48] zmo: basically what I mean is that I used to have: `FooBar(a,b,c)` which became: `FooBar(a, bar:Bar)` with `Bar(b, c)`, I did the migrations and all, added the belongs/has_many, and then I created a `def b; self.bar.b; end` to keep backward compatibility
[09:18:15] zmo: my issue is the following: how can I keep my backward compatibility method, without it to break migrations when pushing my change?
[09:19:37] zmo: is there a way for me to enable the methods only if the migration has passed? or in the migration is it possible to access values by column (like update_column, but just to get the column's value?)

2018-06-14

[07:42:39] zmo: Ping timeout: 256 seconds
[07:57:13] zmo: has joined #ruby

2018-06-11

[07:39:22] zmo: Ping timeout: 264 seconds
[07:45:47] zmo: has joined #ruby

2018-06-09

[18:03:28] zmo: has joined #ruby
[18:03:51] zmo: I'm getting an exception such as: `NoMethodError: undefined method `name' for #<Hash:0x000055ca65ee83d0>`
[18:04:15] zmo: and I'm having a hard time finding out what's in the hash being referenced
[18:04:43] zmo: I was wondering if it was possible to get the hash's content using the object's reference address
[18:05:06] zmo: i.e.: `0x000055ca65ee83d0` in my example above
[18:36:07] zmo: well, it's within a lib that transforms the data I'm giving to it
[18:37:08] zmo: basically, I'm transforming a hash into an object (using the HashIt snippet found through google/SO)
[18:37:36] zmo: and it fails to transform an encapsulated hash, and I need to find why
[18:50:27] zmo: hm it's definitely not local though :-/
[18:53:18] zmo: though I think I found the culprit hash… now I have to find out why it's not transformed

2018-04-25

[12:25:50] zmo: *.net *.split
[12:27:29] zmo: has joined #ruby
[12:27:33] zmo: has joined #RubyOnRails
[15:01:21] zmo: *.net *.split
[15:03:05] zmo: has joined #RubyOnRails
[15:03:12] zmo: has joined #ruby

2018-04-14

[10:53:39] zmo: has joined #ruby
[10:53:39] zmo: Changing host
[10:53:57] zmo: has joined #RubyOnRails
[10:54:03] zmo: hi 🙌
[10:55:01] zmo: I got a question about STI… is there a mechanism in ActiveRecord/Rails so that I can query a list with polymorphism applied?
[10:56:11] zmo: like I got `class X < ActiveRecord:Base`, with children `class A < X`, `class B < X`, `class C < X`
[10:57:02] zmo: I have a `class Foo` that has a has_many relationship with X
[10:57:22] zmo: (through member `Foo.list_of_x`)
[10:58:03] zmo: if I create a bunch of A, B, C, linked to a single Foo row, that works fine
[10:58:49] zmo: but if I want to access `Foo.list_of_x` I get a bunch of `X`… is there a way I can have that list with polymorphism applied, so I get a bunch of A, B, C and not X?
[11:33:45] zmo: ok, I found that I can do `Foo.all.sample.list_of_x.map{ |elt| elt.becomes(elt.type.constantize) }`
[11:34:18] zmo: but I believe there's a better way to do it, maybe a tad more efficient (even if efficiency in this context is not my prime concern)

2018-03-12

[12:08:49] zmo: I'd like to make a member from a parent class available as self attribute in the children classes.. I thought it would be obvious, but it actually isn't. I tried doing it the same way I defined class methods (self.name) but no luck
[12:08:59] zmo: I tried with @@name
[12:11:15] zmo: how can I have a class member and access it from a child's method ?
[12:14:34] zmo: class A; self.a = 42; end ; class B < A; def foo; print(a); end; end
[12:16:05] zmo: hm.. actually what I really want, beyond the syntax is the opposite pattern: class A; def foo; print(self.a); end ; class B < A; self.a = 42; end
[12:16:12] zmo: so that B.foo prints 42
[12:16:18] zmo: (B.new.foo)
[12:17:09] zmo: Burgestrand - yes, I want to access A.a from an instance, without having to know the class name
[12:17:41] zmo: Burgestrand - indeed, but it's the same mechanism
[12:20:44] zmo: ok, thanks, I'll try that
[12:21:35] zmo: well, I'm just implementing a specialization pattern, so it should be fine
[12:21:40] zmo: even though the @@ syntax is ugly :)
[12:22:58] zmo: ah, that's indeed more elegant
[12:23:10] zmo: I'll do it that way, thanks

2018-03-10

[22:44:28] zmo: Ping timeout: 240 seconds
[22:45:44] zmo: has joined #ruby
[22:45:44] zmo: has joined #RubyOnRails

2018-02-28

[12:37:31] zmo: little question : I got a function from an external module (https://github.com/utsavkesharwani/hypertrack-ruby/blob/master/lib/hypertrack/api_operations/common/nearby.rb) which I want to modify (and ultimately offer a PR), but for the sake of experimenting my changes before submitting a PR, I'd like to monkey patch that method with one of my own from my own code
[12:38:02] zmo: basically, replacing that method in that module with one I write in the context of where I use it
[12:38:44] zmo: I've seen many methods of monkey patching in ruby which offer a wild variety of monkey patching, but how can I replace a Module's method with another one, binding that method to its context ?
[12:39:54] zmo: so I just add on top of my own module a module X / module Y / module Z / module T / def foobar end / end / end / end, and X::Y::Z::T.foobar will be replaced ?
[12:40:41] zmo: of course, I'm doing rails, so I feel like the entire world is loaded before my code runs anyway :)
[12:41:41] zmo: I'm struggling with knowing what's in the env at any moment in rails
[12:41:50] zmo: (it's actually killing me)
[12:42:06] zmo: well, it's still only an experiment
[12:42:13] zmo: if I get it right, I'll submit a PR anyway
[12:42:18] zmo: and I'll point the gem to my fork
[12:44:37] zmo: yup, but I'm running in docker-compose, and it's more painful to shut it down, rebuild, re-up etc. just for a gem change
[12:45:24] zmo: (and actually doing it again if my guess is wrong)
[12:45:41] zmo: with monkey patching, I'd only do it once
[12:45:45] zmo: thanks again :)

2018-02-27

[17:44:09] zmo: how could I do the following python pattern in ruby with Hashes? `some_func(**dict(zip(['param1', 'param2'], ['value1', 'value2'])))`
[17:44:46] zmo: in other words, I got two arrays : ['param1', 'param2'] and ['value1', 'value2']
[17:45:30] zmo: and I want to pass it as arguments to a function so that function is called like `some_func(param1: :value1, param2: :value2)`
[17:46:00] zmo: well, sorry, consider I said: [:param1, :param2] and [:value1, :value2]]
[17:46:09] zmo: s/]]/]/
[17:46:42] zmo: apeiros - well I intended to do both :)
[17:47:13] zmo: apeiros - no worries, I would have said the same ;-)
[17:47:28] zmo: that's actually pretty close to the python way :)
[17:48:06] zmo: yup, it's only symbols (which is one nicety that ruby has and python doesn't :) )
[17:48:53] zmo: apeiros - I really file I just asked the question : "what's the english word for the french word 'restaurant' ?" ^^
[17:49:19] zmo: s/file/feel/
[18:10:49] zmo: BTW, I just noticed
[18:11:09] zmo: thank you apeiros 🙌

2018-02-20

[19:31:54] zmo: it should be half of that
[19:32:28] zmo: apeiros - you're loosing the frustration of the exageration
[19:32:39] zmo: s/of the/in the/
[19:32:47] zmo: and s/loosing/losing/
[19:33:37] zmo: I guess I should call it a day
[19:33:56] zmo: (though, it really takes two g ? oO)
[19:34:10] zmo: (learned a thing today)
[19:36:05] zmo: apeiros - lol, it got filtered
[19:39:12] zmo: tests are for loosers
[19:47:30] zmo: anyway, calling it a day
[19:47:49] zmo: thank you 🙌
[19:47:52] zmo: ACTION &