Activity Graph

Page 1 of 3 | Next »


[00:34:12] et09: has joined #ruby
[00:34:37] et09: editing someone else's code - he defined a class getter 'payer_cost' and also defines that as a variable in a method
[00:34:49] et09: in that same method, the local one takes precedence, right?
[00:39:07] et09: Quit: leaving
[00:39:07] et09: looks like that's a yes


[17:00:55] et09: has joined #RubyOnRails
[17:01:04] et09: header for AJAX post is called X-XSRF-TOKEN, right?
[17:01:39] et09: getting 422's with an apparently vavlid token i grabbed from <%= hidden_field_tag :authenticity_token, form_authenticity_token - %>
[17:05:22] et09: ah - X-CSRF-TOKEN
[17:46:10] et09: Quit: leaving


[19:21:33] et09: has joined #RubyOnRails
[19:21:56] et09: having a million problems for yarn + webpacker on rails... "Your yarn packages are out of date / Please run `yarn install` to update" despite yarn install being up to date
[19:24:38] et09: something to do with the wrong node version? i'm really confused
[19:30:43] et09: nevermind, disabled yarn a la
[19:30:46] et09: Quit: leaving


[18:44:58] et09: has joined #RubyOnRails
[18:45:11] et09: i want to add a babel plugin to the default rails new --webpack config - where do i do it?
[19:12:34] et09: nevermind, .babelrc was answer
[19:12:35] et09: Quit: leaving


[12:26:39] et09: Ping timeout: 256 seconds
[12:27:24] et09: has joined #RubyOnRails
[15:42:38] et09: Quit: leaving


[20:40:38] et09: has joined #RubyOnRails
[20:41:06] et09: what possibilities are left if i'm getting a bunch of InvalidAuthenticityToken errors, but for each of them, there's a X-Csrf-Token
[20:41:18] et09: and a _csrf_token in the session
[20:41:37] et09: X-CSRF-TOKEN in the request headers **
[21:06:03] et09: it's all over the place. JS code
[21:06:10] et09: but they're all sending that header
[21:06:33] et09: my theory is someone reset a session in another window, and then it's sending the old csrf token or something? the session store is in a cookie


[15:41:28] et09: Ping timeout: 240 seconds
[15:43:22] et09: has joined #RubyOnRails
[17:14:35] et09: Ping timeout: 240 seconds
[17:15:11] et09: has joined #RubyOnRails


[15:54:40] et09: Quit: leaving
[16:06:03] et09: has joined #RubyOnRails
[16:06:23] et09: i have a huge query with aliased subselects and joined columns and other crap, and of course rails is trying to jam it into the model can i get the raw sql tuples?
[16:06:30] et09: or the raw sql result
[16:11:10] et09: do i have to do .to_sql and then go around and do ActiveRecord::Base.connection.execute [...]
[16:12:04] et09: alternate phrasing of my there an equivalent to "pluck" that returns hashes?
[16:12:43] et09: well...can i get the column names?
[16:12:58] et09: this is actually nauseating
[16:14:45] et09: i'm OK doing .to_sql and grabbing the results, if there's no better way.
[16:21:38] et09: can i chain .select methods?
[20:56:59] et09: Ping timeout: 240 seconds
[20:57:17] et09: has joined #RubyOnRails


[16:20:16] et09: has joined #RubyOnRails
[16:20:50] et09: i want to jump in and out of a second database i have defined in my config/database.yml for only two controller actions, which don't rely on my models. is there a best practice?
[16:21:48] et09: i think ActiveRecord::Base.establish_connection will screw something up?
[16:35:37] et09: i see, so what i did was class SecondDb < ActiveRecord::Base // self.abstract_class = true // establish_connection(:second) // end, and then i'm using SecondDb.connection.execute(...). is that all correct?
[17:00:57] et09: too many different tables to create duplicate models for
[17:01:05] et09: it's a replica
[17:01:44] et09: as long as my solution doesn't accidentally use the main db or something, that should be fine
[17:08:45] et09: oh, i see, nifty
[17:10:25] et09: i didn't know you could set options on a thread like that
[17:31:10] et09: matthewd: it seems to break on the :primary, i changed it to Rails.env.to_sym, but then it gives me "No connection pool with id development found", which uh...well, there's an entry in config/database.yml for development
[17:33:09] et09: same, s/development/primary/
[17:35:26] et09: maybe i should call super?
[17:36:41] et09: "primary" as a string
[17:38:39] et09: yess beautiful +1
[17:49:30] et09: ah no. "replica" doesn't reference anything either.
[17:49:50] et09: matthewd. do i need to create a second connection specification or something?
[17:50:57] et09: doesn't appear to be. this is 5.0.2 btw, not 5.1 (my mistake)
[17:51:23] et09: "primary" isn't referenced in database.yml, only "development", "staging", etc.
[17:54:23] et09: well - ActiveRecord::ConnectionNotEstablished: No connection pool with id replica found.
[17:54:34] et09: and replica is def. in database.yml
[17:56:17] et09: should i just do ActiveRecord::Base.establish_connection(:replica) and then ensure ActiveRecord::Base.establish_connection(:primary) or similar?
[18:00:28] et09: your solution worked with rails 5.1?
[18:05:20] et09: what about 'configurations' in those lines?
[18:12:18] et09: how can i check if it already exists
[18:12:40] et09: this is what i have
[18:14:17] et09: it's still not working
[18:14:29] et09: ActiveRecord::ConnectionNotEstablished: No connection pool with id replica found.
[18:15:13] et09: i put those two lines into an initializer
[18:18:29] et09:
[18:20:47] et09: how can i check within the block if i'm on the replica?
[18:20:56] et09: { } block, in my controller
[18:21:31] et09: this gives me replica, but not sure if it's accurate
[18:21:38] et09: i mean, that gives me "primary"
[18:22:26] et09: it's the same server on dev
[18:22:55] et09: "primary" lol
[18:24:43] et09: oh well if i puts from connection_specification_name, it shows 'replica' when i call something in the block
[18:24:48] et09: is that sufficient proof?
[18:25:29] et09: but then won't the app not start?
[18:27:27] et09: ok, looks good i think
[18:59:29] et09: defsdoor: there's a generator for that
[19:22:18] et09: emers2n: inspect the query and replay it in console. request 'accept' type is probably different for one
[22:01:25] et09: Ping timeout: 276 seconds
[22:02:38] et09: has joined #RubyOnRails
[22:15:58] et09: Ping timeout: 246 seconds
[22:23:04] et09: has joined #RubyOnRails


[18:02:37] et09: has joined #RubyOnRails
[18:02:55] et09: i wanna make sure i have this right - rails g migration [...] user:references, this will add a foreign key constraint - and this - rails g migration [...] user:belongs_to - this won't?
[18:22:47] et09: Quit: Lost terminal


[20:48:17] et09: has joined #RubyOnRails
[20:48:31] et09: i have two joins, @bookstore.books and @customer.books. how do i find the intersection?
[20:52:21] et09: Client Quit
[20:52:21] et09: n/m, thanks


[15:01:15] et09: has joined #ruby
[15:02:58] et09: i have [1,2,3,4]. i want to say, please execute ->(x){x**2 == 9} and return the x**2 for the first match (or whatever computation). i.e., please return the return value of lambda x of enumerable y that is truthy
[15:03:10] et09: is there a non-manual way to do that
[15:05:33] et09: lazy! omg
[15:05:45] et09: when did they add that
[15:06:16] et09: it's doing a database query for each member, in my actual case
[15:06:31] et09: trying to resolve a polymorphic association on a list of objects
[15:06:34] et09: in priority
[15:06:45] et09: hxegon: trying to avoid the double-query
[15:11:48] et09: you're probably right
[15:13:03] et09: this query would prob never exceed 2ms
[15:13:27] et09: although uh, the list is prioritized
[15:13:45] et09: so it'd have to order and then limit...
[15:14:10] et09: Papierkorb: and a max base set of length 3
[21:39:22] et09: Quit: leaving


[16:54:52] et09: has joined #ruby
[16:55:02] et09: is there a way to do Hash#select where it separates it into two hashes, matching and not matching?
[16:56:53] et09: they both give arrays -_-
[16:57:34] et09: >> {a: 2, b: 3, c: 4}.group_by {|k,v| v % 2 == 0}.map{|k,v| v.to_h}
[16:57:37] et09: i guess that's ok
[21:51:48] et09: Read error: No route to host


[02:52:26] et09: Quit: leaving


[18:47:15] et09: has joined #ruby
[18:47:27] et09: what's the equivalent of mkdir -p for a ruby Hash? or phrased differently, the setter version of Hash#dig ?
[18:48:12] et09: if any exists
[18:52:12] et09: is it bad practice to map a 3-deep function call across a huge array of hashes? i'm getting very poor performance doing it
[18:52:45] et09: i.e, get a proc that does an inject of an array of procs across a hash, and then map that on the array
[18:53:06] et09: to be specifically actually, these are lambdas
[18:56:03] et09: all dependencies considered, it's a few hundred lines of code, i just gave the "what you need to know" summary
[18:59:54] et09: that might help me refactor
[19:01:33] et09: that's basically it, just the functions being injected on the hash are basically "recursive_send" on an OpenStruct (recursive_send just being a bunch of .send's piled on top of each other)
[19:05:11] et09: i just used this
[19:05:30] et09: but this is actually foolish on my part. i should be using OpenStruct#dig
[19:05:32] et09: in most cases


[13:58:30] et09: has joined #ruby
[14:08:46] et09: Quit: leaving


[18:36:07] et09: has joined #ruby
[18:36:49] et09: im having a really weird problem, i define a proc and then do{|x|} - and every item in the result array is based on the last item in the source array
[18:40:52] et09: i can't post the code :( it's proprietary
[18:41:06] et09: but shouldn't that be impossible ??
[18:42:03] et09: they're hashes
[18:42:35] et09: a single hash reference?
[18:44:18] et09: it's an array of separate hashes with no circular references
[18:45:15] et09: the object id?
[18:46:09] et09: is the same as result.count
[18:47:13] et09: (grinds teeth)
[18:53:55] et09: i think i actually hit a bug in ruby
[18:54:05] et09: either that or this code really does not work as expected
[18:59:09] et09: like if i do
[18:59:24] et09: result_array ={|x|}
[18:59:28] et09: i actually get a different result than
[18:59:39] et09: result_array = []; result.each{|x| result_array <<}
[20:57:07] et09: eam: i figured out the problem
[20:57:32] et09: the proc generator was not instantiating a new object for its assignments each time, it was using the same one
[20:57:52] et09: 3 hours down the drain, just needed to add a ".dup" ;____;
[21:29:31] et09: it was deceptive because the proc instantiation itself was creating that object which the reference went to
[21:31:07] et09: it was deceptive because the proc instantiation itself was creating that object which the reference went to
[21:32:17] et09: ruby-lang795: is it a one dimensional hash
[21:32:35] et09: then split by comma
[21:32:48] et09: yeah it's unsafe
[21:35:08] et09: is it a ruby hash to begin with?
[21:35:13] et09: or a json hash perhaps?
[21:35:25] et09: n/m i see nil, not null
[21:37:14] et09: how many records are you dealing with
[21:37:36] et09: then change the code dealing with their format asap
[21:37:44] et09: if you're using postgresql you can use json/jsonb types
[21:37:56] et09: automatically (de)serialized to activerecord and vice versa
[21:38:09] et09: they have it too now
[21:38:10] et09: as of 5.7.8
[21:39:35] et09: since you can visually inspect the data set, you can easily run eval against it during the migration, if you determine it's safe (which god knows it prob is)
[23:06:14] et09: Quit: leaving


[04:11:45] et09: has joined #RubyOnRails
[04:11:58] et09: if a client initiates a request to rails, and it's received successfully, is there anything whatsoever a client can do to stop the request ?
[04:12:14] et09: ie halt the code
[04:13:39] et09: dumb question i assume..
[04:49:42] et09: Quit: leaving


[00:06:25] et09: Quit: leaving


[20:59:25] et09: has joined #ruby


[05:02:27] et09: has joined #ruby
[05:02:44] et09: lambda{|x| foobar(x)} === ->(x){ foobar(x)} correct?
[05:09:17] et09: hey Radar long time no see
[05:57:12] et09: Quit: leaving


[20:45:24] et09: has joined #ruby
[20:45:37] et09: a = {b: nil} <--- how do i distinguish a[:b]'s "nil" from a[:foobar]'s nil
[20:46:13] et09: ah, thanks
[20:46:15] et09: Client Quit


[18:11:05] et09: has joined #ruby
[18:11:11] et09: i have an array ['to_i','minutes']
[18:11:19] et09: how do i turn it into a proc which calls those two methods sequentiallyw on a value
[18:11:24] et09: or a lambda really
[18:11:52] et09: ah brilliant, thanks
[18:13:26] et09: well the only thing is i don't want the proc to contain the array
[18:13:34] et09: i want it to just point directly to the methods
[18:13:40] et09: speed is kind of a concern
[18:15:03] et09: it's an interesting story lol
[18:15:43] et09: calls is programmed-defined
[18:15:46] et09: programmer*
[18:15:55] et09: so it's not the end of the world
[18:21:40] et09: it works
[19:41:42] et09: Quit: leaving


[18:30:27] et09: has joined #RubyOnRails
[18:30:41] et09: are there alternatives to html.erb, .html.haml? can i use something like jade or other?
[18:30:55] et09: trying to convert about a hundred angular-infused html files to haml and it's not working
[18:31:04] et09: ampersands deleted and such
[18:34:56] et09: conversion actually seems better
[18:35:18] et09: how's that
[18:35:27] et09: oh, yeah
[18:35:43] et09: i've had a lot of success in the pasts
[18:36:37] et09: that was what was giving me problems
[18:36:49] et09: it deletes html special chars inside attributes thus breaking all my angular
[18:39:38] et09: .order is right
[18:40:08] et09: .order(...).last or .order(...).first
[18:49:00] et09: Quit: leaving


[20:44:03] et09: has joined #RubyOnRails
[20:45:02] et09: if i have a concern 'Foobarable', is there a way to say, include this concern if the record has attribute baz == true
[21:21:46] et09: Quit: leaving


[02:10:36] et09: Quit: leaving


[22:07:48] et09: has joined #RubyOnRails
[22:08:13] et09: is there a rails-level way to say, when Foo.mapping_id == Bar.mapping_id, set Foo.bar_id =
[22:08:17] et09: for an entire table
[22:12:35] et09: trying to do a bulk insert of both tables (via activerecord-import) with a matching asigned random id, and then join them afterwards
[22:14:17] et09: that won't work
[22:14:28] et09: it's literally a single insert statement for many thousands of records on both tables


[22:12:22] et09: i don't even have access to the file right now, lol, so i can't test
[22:12:27] et09: have to find an example online
[22:12:36] et09: but i can see how that'd work
[22:14:05] et09: it's a preset three char string so FOO is fine here
[22:14:14] et09: er, four
[22:16:17] et09: the string never starts with FOO
[22:16:28] et09: yeah, that is the case
[22:16:35] et09: that will happen
[22:22:12] et09: oh it needs to traverse \r too
[22:24:38] et09: guess that's not s flag like i thought
[22:25:22] et09: oh [\s\S]. got it
[22:28:33] et09: ok, thanks
[22:28:35] et09: Quit: leaving