#RubyOnRails - 03 October 2018
Forward 1 day »
[07:32:43] dionysus69: I had regular has_many relationship and the parent expected child class to be ParentClass::ChildClass instead of just ChildClass
[07:33:13] helpa: You have not provided enough information to debug your problem. Please provide this information: https://gist.github.com/radar/5384431
[08:04:12] Psy-Q: is it evil coupling if i set some defaults on a model before saving and those defaults are different depending on whether some other model is associated to it? e.g. DatabaseConfiguration will produce unique database names when saved on its own, but if there is an associated HostingConfiguration it will create a prefix for each database based on details from there
[09:05:55] ss942: I'm trying to do it with Rails, and it's not working in way I predirected. I tried this
[09:05:55] ss942: TOne.joins("INNER JOIN t_two ON t_two.id = t_one.t_two_id") .where("LOWER(t_two.name) LIKE (?)", "exemple").first().id()
[10:49:47] dionysus69: so I am getting into real scaling and real production infrustructure, and I need a very very important advice, what toolchain to use. I have heard of chef and docker and kubernates, which one do you guys use and why? and which one do you recommend for start?
[10:51:14] dionysus69: at the moment I have a basic infrustructure, the only separate node is the redis VM and I use capistrano for deployment. I was thinking that instead of continuing to scale up manually, I should look into orchestration methods
[12:53:57] Arkentias: Hey everybody! I'm looking for a nice way to handle image uploads to S3 with different sizes per image everytime. I think ActiveStorage might have been an ~OK fit but some of the fields that need to contain those images are elements of a JSONB attribute. I'm under the impression that ActiveStorage needs some root model relations to function correctly
[12:54:19] Arkentias: Am I right? Would I be better off just writing my own solution since it's not THAT hard to do?
[13:00:47] tycoon177: Arkentias: activestorage requires a model, yes, but that's all that would be needed. i wouldn't roll your own solution with this being readily available
[13:01:05] tycoon177: there's no requirement for other associations on the model or anything like that
[13:02:05] Arkentias: The "has_image" thingie is not related to an attribute at all in fact? it's just an arbitrary name?
[13:03:15] tycoon177: you'll probably want has_one_attached https://edgeguides.rubyonrails.org/active_storage_overview.html#has-one-attached
[13:04:10] tycoon177: sorry to run, but i have to head to work. feel free to tag me in a message if you have any questions..i'll be back within an hour
[13:04:14] Arkentias: OK yeah but the DB attribute will be in the tables that active storage creates, not in my model's schema I guess
[13:17:41] dionysus69: any ideas why sidekiq is creating 51 connections when I have concurrency set to default 25?
[13:20:25] Arkentias: I don't know a lot about this but maybe this could help https://github.com/mperham/sidekiq/wiki/Advanced-Options#connection-pooling
[13:21:37] dionysus69: I think it's for throttling certain workers not to use more than given number of connections
[13:24:12] logik-bomb: I'm playing with models and namespaces but I'm a bit lost regarding associations. How should I define this migration? Thanks https://gist.github.com/alopes/6408daaba612f000e17afabb3cc408a0#file-ruby-rb-L33
[13:30:55] Arkentias: In your AutoModels migration you can also simply write "t.belongs_to :brand, index: true" instead of using references but I think ereferences works too
[17:31:04] istrasci: I'm trying to create a gem with a dash in the name, and include it (locally) into a Rails app. When I run rails console, I get "[error]: Error loading plugin 'my-gem'". If I create a similar gem with an underscore in the name, it works fine. Any ideas?
[17:39:30] TACTICALNEURALIM: How do you get Rails to render pre-existing JSON? render :json foo tries to JSONify foo. Foo is already JSON. I cannot remember how this is done and my searches keep finding irrelevant stuff
[21:34:19] bousquet: anyone used activeresource lately (this year)? Is this gem still alive or are there ways to wrap rest apis for consumption?
[23:30:48] bothari_: I need a little practical advice. I had a great interview for a rails spot, but found out they want to hire me 1099. I've only done contracts through TEK Systems. Anybody here done something similar?
[23:31:18] skangas: Hi! I'm seeing spurious "NameError: uninitialized constant" when running unit tests. It seems that my exception classes are somehow not loaded - but this does not happen consistently. It seems to happen randomly.
[23:33:54] havenwood: bothari_: I've worked as a contractor before. Anything in particular you're wondering?
[23:40:28] havenwood: bothari_: If it's in the US, you can use a Form 8919 to see the difference in social security and medicare taxes: https://www.irs.gov/pub/irs-pdf/f8919.pdf
[23:42:02] skangas: It seems it only loads the class file when I use a class by that name. Interesting stuff for a beginner like me.
[23:42:20] skangas: So where would I normally place exceptions if not bundled with the relevant base class?
[23:42:27] havenwood: bothari_: I guess it's the US since you said 1099. So I'd suggest looking at whether they're misclassifying as well.
[23:42:50] skangas: I mean, to avoid errors if the exceptions are referenced before the class that they are bundled with.
[23:43:44] havenwood: bothari_: It's unfortunately fairly common for employers to intentionally misclassify. There are remedies though - talk to an employment lawyer ideally.
[23:47:17] dogweather: skangas: I believe that standard practice is to place all custom library code into /lib. And your exception classes wd be an example of that
[23:53:17] skangas: dogweather: Thanks. I'm still confused as to why my current exception classes are not autoloaded, and how it would be different if they were in /lib.
[23:53:43] skangas: Right now, they are only loaded when I use the class associated with that file (as service objects) -- maybe this is why?
[23:54:20] dogweather: Yeah, let the Rails framework handle that for you. You'll just be fighting against it otherwise
[23:54:58] skangas: There must be some magic associated with service objects that is probably not there for the /lib directory then in terms of auto-loading
[23:55:05] dogweather: If you want a lighter weight web framework for services you can look at sinatra
[23:56:17] skangas: I just have to know when to keep away, and clearly I just stumbled into a marsh...
[23:56:30] dogweather: Yep, it's not a normal Ruby app in that sense - it has its own loading and autoloading behavior
[23:57:15] skangas: OK, so next order of business is probably to move my external service processing to "/lib"
[23:57:51] skangas: I was slightly confused when trying that earlier though, in particular of how to make unit tests for "/lib" that I can run with "rails test"
[23:58:07] dogweather: 's my personal preference. And then if you want, you can add the /lib directory to be easier to develop with, by not caching it
[23:58:10] skangas: I've been googling a ton but all the links seem to talk about Rails 3 and things seem to have changed
[23:58:59] dogweather: I use rspec, and there, I just make sure to mirror the dir structure. That may work for tests too
[23:59:13] skangas: Having done quite a bit of (web) developing before (also using frameworks) I'm very impressed so far