Page 1 of 38 | Next »
[17:03:46] mwlang: I think I’ve forgotten something subtle about ActiveRecord. Why would deleting a child record that belongs to a parent class issue a DELETE for the parent record? The child class depends on the the parent, so if parent is being destroyed, sure, delete the child, but not the other way around...
[17:29:51] mwlang: I started a transaction block, deleted all the child records, then deleted the parent record at the end of that transaction block.
[17:30:23] mwlang: it’s the call to delete the parent record that’s triggering the FK constraint on the child table (whose records I’ve already deleted…)
[17:30:55] mwlang: the DBMS just isn’t seeing the record as deleted yet, so it’s the DBMS raising the FK constraint error, not AR.
[19:16:14] mwlang: broppk: 12 years later, Ruby is still my go-to language of choice and I don’t see myself giving it up any time soon. I do some Node JS, but mostly within context of a Rails project, which means React and Webpack, etc. tied into a Rails-driven backend serving the databased JSON to the JS frontends.
[19:19:57] mwlang: most of the latest JS stuff is still arm’s length for me. I can usually do all the JS I need with simple jQuery widgets written in coffeescript. If I need more, I usually step up to VueJS instead of React, Webpack and all that. Only two projects are utilizing the heavier weight JS tooling.
[19:21:22] mwlang: I guess it all goes back to the RJS days of Rails and since that big ball of mud, I’ve always tried to keep external components to a bare minimum.
[13:34:49] mwlang: How do I turn off logging ActiveJob in Rails 5? The method used in Rails 4 and everything I can google says “ActiveJob::Base.logger = Logger.new(nil)” but this is not doing the trick any more
[13:36:21] mwlang: It may be that resque is injecting the info into the log since I’m seeing… “Performing BroadcastOrderBookJob (Job ID: 168a169c-11f1-4ee6-9af7-fa13ffcf907d) from Resque(default) with arguments:” rather than ActiveJob proper?
[13:45:07] mwlang: nevermind, it turns out that placing the code in an initializer file was the trick vs. placing it in application.rb or in the environments/*.rb files.
[17:32:47] mwlang: is there a gem out there supporting .Net’s signalr websockets? I’m having trouble tracking one down.
[17:34:18] mwlang: it may not be horse power of the arm board, but rather a lack of necessary system packages.
[17:49:11] mwlang: I learned a lot of good Ruby tricks from the Sequel source. Definitely worth a study.
[18:04:23] mwlang: I don’t know if “associative array” is correct term for a Hash. key/value mapping seems more appropriate.
[20:02:18] mwlang: havenwood: embed #ruby irc channel in irb console!? You gotta build that! I can just see it now…an interactive Ruby shell that emits IRC messages as they come through while you’re working on something…and you can reply back with simple command => irc :ruby, “yeah, I got it.”
[20:05:37] mwlang: for any of you that are into crypto currencies and trading on exchanges, I put out a new open source gem that wraps cobinhood’s api: https://github.com/mwlang/cobinhood I’d love some feedback on how to improve this code (aside from the most obvious: writing some specs for it…)
[20:07:18] mwlang: speaking of writing specs, for open source projects that may have sensitve server exchanges, what’s the typical approach to implementing? last thing I want to do is accidentally expose my private API keys through VCR cassettes and/or other means of fixture capturing.
[20:20:35] mwlang: Good points on all, but I didn’t understand one: Frozen string literal magic comment?
[20:32:07] mwlang: I’ve been using !~ and =~ for quite some time just because I like it better than reading “match?” but an performance boost is enough for me to change.
[20:32:45] mwlang: truth be told, most time lost on the actual API call/response than anywhere else.
[20:45:03] mwlang: on the frozen literal string magic comment, if I add that, I should remove the #freeze call, right? https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/api_endpoints.rb#L43 for example.
[20:50:25] mwlang: havenwood: thanks for that detailed look and feedback. I definitely wasn’t expecting that and really appreciate it. I’m probably going to do a few more of these for various exchanges, esp. if the current ones out there royally suck like the cobinhood_api one did.
[20:50:57] mwlang: kucoin comes to mind. terrible implementation of a ruby wrapper on the existing gem.
[20:52:49] mwlang: one other performance idea: someone told me to switch the Faraday default adapter to Typhoeus. any opinions here on the merits of that suggestion?
[21:00:53] mwlang: hmmm…are you sure about “ ENV:: always returns a String” ? I just tried this in IRB console: ENV["SOMETHING"] => nil
[21:07:40] mwlang: all I needed to know at the point of using an api_key is whether it was blank/empty or not.
[21:12:25] mwlang: pushed a new version with the nitpicks cleaned up. @Eiam this is where I’m using that #to_s: https://github.com/mwlang/cobinhood/blob/master/lib/cobinhood/client/rest/auth_request_middleware.rb#L10
[21:15:54] mwlang: this way, error’s raised only first time an endpoint requiring the key is called.
[22:28:47] mwlang: Ah. I’ve been a long-term “investor” from point of view of simply holding and growing COB stack simply trading the gap in the spreads on the platform.
[22:30:20] mwlang: If you’re into cryptocurrencies, you may also like another open source Ruby project I have going: https://github.com/mwlang/crypto
[22:30:43] mwlang: I do. They seem to have a great team and constantly working on improving the platform.
[18:06:52] mwlang: So I’m building my first Rails 5.1 app with ActionCable subscription. I can successfully trigger a broadcast from a web browser that will eventually update back to the browser client that triggered the action (like the demo chat program).
[18:07:24] mwlang: but when I fire up rails console and submit a broadcast, it never reaches the browser client that is subscribed to the channel.
[18:08:54] mwlang: My goal is to have a background job running every 5 ~ 10 seconds that will send a trigger a broadcast to all subscribed clients.
[18:09:51] mwlang: So a background job via ActiveJob that’s running in it’s own worker is never going to successfully trigger broadcasts to the server connected clients?
[18:18:28] mwlang: decided to open-source it…nothing proprietary in the app…need a couple minutes to get it published so I can gist some code properly.
[22:25:48] mwlang: is it possible for a rails session that’s a database/activerecord store to be explicitly set by passing the session_id in on URL?
[22:26:20] mwlang: For example, we want to implement Google Docs preview functionality whereby a logged in user can view a document.
[22:27:12] mwlang: since the request for the document’s data payload is coming from docs.google.com, we need docs.google.com to “auto-login” to the user’s current session.
[22:39:56] mwlang: blindMoe: in config/application.rb, set config.active_record.default_timezone = :local
[22:40:13] mwlang: and you’ll also want to set the timezone you want while you’re at it: config.time_zone = "CET"
[22:42:01] mwlang: I’m reasonably sure the second setting is crucial to getting the behavior you want.
[22:45:02] mwlang: ok, monkeying with UTC in the DB probably isn’t the solution you want anyway…if you have multiple timezones serviced by the app, it’s best to keep it UTC in the DBMS.
[22:46:33] mwlang: If you’re running in a cluster and the expectation is each server serves a specific timezone, then my thought would be to try setting the server’s timezone so that it’s cronjob scheduler is firing the midnight tasks at midnight local time for that server.
[14:50:06] mwlang: I’m trying to use Time.at(1504227567) to get back the right value in UTC timezone. The problem is, I’m getting back that time interpreted to my local timezone. How do I cast the local time to correct UTC time?
[14:52:38] mwlang: actually, I just realized the fallacy of my reasoning…casting the local time to UTC with #utc appears to be the number I expected.
[14:08:08] mwlang: For years, I have always kept database.yml in .gitignore and out of the repo, but I’m working my first Heroku hosted project since ~2008 and it seems that database.yml must be checked into repo for a successful heroku deployment.
[14:08:58] mwlang: So my question: How are others that host to Heroku handle this because what I’m finding is my team’s struggling to remember to keep their local changes out so that the production relevant version stays put in the repo.
[14:21:18] mwlang: matthewd: I think you have a point about “not needing to make local changes” we’re all connecting to postgresql, but one’s on Linux, another on macOS and another is running his posgresql server in one VM while running the rails app in another, so I guess we’ll have to go to environment variables to hold user, host, password values.
[14:40:00] mwlang: fryguy: what does that magic script look like? Am I presumely correctly it’s a bash script?
[14:44:29] mwlang: fryguy: alright, I’ll find a way to do it with bash if the client’s not open to doing ERB with environment variables in the file.
[19:14:49] mwlang: Just implemented this change to root route definition today. Haven’t deployed to production yet. Would love a sanity check on this idea: https://gist.github.com/mwlang/1ae93907b6ebcb156fdc0db6e0de3cfa
[19:16:09] mwlang: Many of those are easily captured with nginx but a few are getting through still. so this is an attempt to gracefully “NO-OP” the few that do.
[13:55:03] mwlang: I’m working on a background job (activejob) that syncs tables/data between two ActiveRecord connections. My problem: The initializer that makes the second AR connection doesn’t run so the sync job references the primary connection for both sets of AR Models. I was able to “solve it” by copying the initializer code to establish the 2nd connection to the job’s perform method, but this is awfully hacky. What’s the correct way to fire the
[13:55:04] mwlang: initializer code before the job runs? FYI, here’s the gist of the working job: https://gist.github.com/mwlang/c954dfeeaf4656847c5b43b2d86004fb
[16:25:55] mwlang: I’m just curious (seeking ideas): How would you refactor this? https://gist.github.com/mwlang/09958e44a202654783e4b24348e9d754
[16:27:18] mwlang: basically, the code’s stopping a delete of a party record if it’s referenced in a number of different scenarios (read: tables)
[16:34:49] mwlang: _moep_: review contents of unicorn-5.3.0/gem_make.out to see what specifically failed
[16:36:21] mwlang: on second thought, re-reading the error chain, if I had to guess, you’re using bundle exec and the unicorn gem isn’t listed there.
[16:55:12] mwlang: not sure if that’s your issue or not, but frequently when test or development start behaving differently from each other, spring is the culprit for me.
[12:20:14] mwlang: when exactly does Rails assign an ID to a session when using database store? Or better, yet, which gem is session implemented in so I can go through the source…trying to track down a weird bug where user sessions seem to get swapped and I think it has to do with a bad session setup sequence in my app controller in which sessions don’t quite behave the way I think they do.
[12:41:48] mwlang: dminuoso: yeah, I think I figured it out. You have to actually set something on the session (i.e. session[:last_visited] = Time.now) before a unique session.id is generated.
[12:44:45] mwlang: yeah. I need to talk to the client about this one…the original app injects an intermediate UserSession object that attempts to link user_id to session_id, but it’s generating gobs of basically empty records.
[15:29:10] mwlang: the original was built back in 2007, so I can’t say I’m too surprised to see “old school” thinking colliding with how AR was intended to work.