#RubyOnRails - 07 June 2018
« Back 1 day Forward 1 day »
[11:23:44] Charliebr73: I am working on a Rails 5, Ruby 2.5 application that uses PostreSQL and Redis, and Redis seems to either struggle or time out when loading large files
[11:46:41] dminuoso: Charliebr73: Are you claiming that redis has some LOADXMLFILE command Im not aware of that is struggling?
[11:50:03] Charliebr73: @diminuoso No. We import xml files to a Rails application. The data is then stored in-memory in Redis. when I try to open that file (and I use the 'monitor' command from Redis CLI to see the process happening), it runs to a certain point and then stops.
[11:51:21] Charliebr73: I have to refresh the page a few times, and sometimes even after that, it does not load the xml content
[12:00:45] dminuoso: "We have a large database..." "Really? How large?" "20,000 rows but it's tweaked so most queries execute in less than 1s"
[12:01:07] dminuoso: ^- transscript of a real conversation Ive once had with someone. I was the second comment.
[12:03:42] tbuehlmann: reminds me of "Big data is like teenage sex: everyone talks about it, nobody really knows how to do it, everyone thinks everyone else is doing it, so everyone claims they are doing it."
[13:04:16] pavelz: hi folks just wonder if anyone seen: SyntaxError: [stdin]:387:28: unexpected = in all .erb files. Happened after upgrade from 4.2 to 5.2
[13:31:55] leequarella: Hi folks, I have a question about ajax:success. My controller has `render js: stuff`. I'd like to hijack ajax:success to stop that from firing under certain conditions.
[13:35:02] dminuoso: leequarella: Just write out an explicit document.addEventListener('turbolinks:load', ...) and fetch the page yourself.
[13:35:53] dminuoso: Most of the rails js/ajax logic is antiquated, weird and depends on a a bunch of undocumented cruft.
[15:31:10] tycoon177: is it bad practice to have a non db-based model? Like, I have some static data that I'd like a model for because it's used across several models and didn't know if it'd be best to just make a PORO or if there's some other way to do this
[15:50:33] NL3limin4t0r: It's not necessary bad to have PORO objects for static data. There are a few things to consider imo. 1) Even static data can be put in the DB to still make use of all the ActiveRecord::Base helpers, if you wan't to make sure nothing overrides the you can set only SELECT permissions on DB level. 2) If you're using your own model it's generaly better to have a PORO than extending from ActiveRecord::Base
[15:50:36] NL3limin4t0r: and trying to spoof all the build in methods, needed to get the whole thing working.
[15:56:09] NL3limin4t0r: You don't really find to much about the best practices of having non db-based models, but that's what I experienced thus far.
[16:33:46] tycoon177: NL3limin4t0r: thanks for the input. I ended up just writing a standard class that doesn't inherit from activerecord::base and ended up just writing a few helper methods to get the right instance. In the end, it creates a maximum of 3 (at this time) objects in memory with 2 attributes each. It just started to get a bit messy with magic numbers flying around due to some legacy code
[20:14:36] spohnz: anyone have a minute to read a stupid question my this stupid man? I may be complicating this too much
[20:15:56] spohnz: I have an index page that shows a mgmt_servers table one of the fields in this table is an int domain_id plucked from another table.
[20:21:38] conr: Found a Rails 22.214.171.124 project on GitHub that is not active. What's the best way to get the gems upgraded to the latest versions?
[20:21:54] dminuoso: spohnz: There's absolutely no chance anyone could make any sense of anything you just said.
[20:22:31] dminuoso: conr: Open an issue. If its not active.. well - maybe fork it and carry the torch?
[20:22:45] spohnz: ok. I have a table called mgmt_servers. It lists an id that is from another table
[20:23:07] dminuoso: spohnz: can you use a gist to show your code from a) your controller, b) the related model and c) the view
[20:25:49] Terens: their is an existing authorization class and all permissions (400 rows) are loaded at every request. Sure they aren't all needed and I wouldnt develop the system like that , however instead of loading what is needed developer suggested to keep globally loaded these data. Is this a bad idea?
[20:27:18] dminuoso: terens: What server model do you have? multi server? multi process? multi thread?
[20:30:00] dminuoso: conr: It appears to have good to high coverage. I would first try to upgrade rails, see if the test suite passes. If not, fix it.
[20:34:49] dminuoso: terens: caching is not a bad idea, but you need a way to invalidate caches. and cache invalidation is hard.
[20:37:26] spohnz: dminuoso: I don't know, do not see a gem for forms. I am just doing a <% @mgmt_servers.each do |mgmt_server| %> to loop through them
[20:39:32] Terens: This isn't exactly caching. And I believe 400 selects at least for every calls is too much IMO
[22:09:23] fourcolors: Hey, I'm having an issue setting window.ENV to Rails.env when I try to do that in my layout file I get an error that says "Rails is not defined" My layout file is in slim
[22:24:11] Radar: I guess on this line: <td><%= mgmt_server.domain_id %></td> is where you want to show the domain name?
[22:24:45] Radar: spohnz: Also I should mention that gist lets you add multiple files to the same gist in a neater way than what you've done: https://github.com/radar/guides/blob/master/using-gist.markdown
[22:28:45] Radar: spohnz: if that's the case, then mgmt_server.domain.name will let you fetch the name through an association