#RubyOnRails - 28 April 2018
« Back 1 day Forward 1 day »
[01:12:08] d6chung: Hi, I upgraded to Ubuntu 18.04 and now running rake segfaults: ../activerecord-184.108.40.206/lib/active_record/connection_adapters/postgresql_adapter.rb:651: [BUG] Segmentation fault at 0x00000000000000. I tried rebuilding but can't seem to get around the issue. This paritcular app is on ruby 2.3.0.
[01:25:55] d6chung: With bundler at first but then I had puma failing to compile, which prompted me to install openssl1.0-dev and that allowed me to proceed with the build -- now I just can't run rake.
[01:28:28] d6chung: I'm thinking it's an Ubuntu-specific issue since I have another box with the same setup that's working fine but was hoping someone here may have encountered it too.
[01:31:24] fryguy: ok, you said you solved the segfault earlier, now you didn't. i'm super confused now
[01:34:22] d6chung: Sorry, let me try to clarify: I upgraded to Ubuntu 18.04 from 17.10; running my RoR app resulted in ruby complaining it couldn't find libraries; so I started rebuilding to hopefully just update references; compilation failed at first but that was due to incompatible openssl, which is resolved; everything is now built but running rake results in the segault, which is where I currently am.
[01:38:27] fryguy: so when you "reinstalled gems" did you actually reinstall gems? or just reuse existing stuff from rvm?
[01:44:57] d6chung: fryguy: No change. It did seemingly fetch and installed everything but rake still segfaults.
[02:09:15] fryguy: any rvm specific errata for ubuntu? i know rvm does some special compilation for things
[02:21:41] d6chung: Not that I'm aware of. I think I'm going to try completely gutting everything and starting over -- rvm and all. Tempted to switch to rbenv.
[05:46:55] dachi: Hello. I have a question about Devise if you use it. How do you separate part of initializer for different environments? I need to set up different omniauth tokens for development and production environments in devise.rb.
[05:48:22] dachi: I can use environment variables with Figaro but I'm just asking if there is some standard way for doing this.
[08:06:17] Cache_Money: I need some help with a SQL/ActiveRecord query. Here are my models: https://gist.github.com/SuperFexy/5eedb7fa124c63fdc5f11cd8ab8148d7
[08:06:57] Cache_Money: For a given site (site_abbreviation), I'd like to sum up all metrics by month (for 1 or more BrightcovePlayer instances)
[08:07:17] Cache_Money: Having trouble thinking about how to solve this within one of my controllers
[08:13:57] Cache_Money: qyliss: No, I'm looking at the sum of video views for all of the @brightcove_players
[08:16:34] qyliss: Cache_Money: I think that would be `@brightcove_players.group(:year, :month).sum(:brightcove_video_views)` or something like it
[08:17:46] Cache_Money: qyliss: I have two separate models. I'm looking for MonthlyBrightcoveVideoPlay.video_views for each of the @brightcove_players
[08:18:41] qyliss: Cache_Money: I think that would be `@brightcove_players.joins(:monthly_brightcove_video_views).group(:year, :month).sum(:brightcove_video_views)`
[08:20:52] Cache_Money: qyliss: Sweet, that's exactly what I'm looking for! I forgot about the .join() method
[19:41:27] srruby: react.js: For a large app do you recommend separate rails apps for serving the api and a second rails app for serving web pages/react components/etc
[20:11:55] tekk: hi, I have a rails runner that I have to keep manually starting (it basically runs a periodic process that requires rails environment)... i've tried to get this to start on system boot by using systemd and rc.d etc... but it seems to spawn multiple instances... is there any ruby/rails specific way of automatically invoking this? My production instance uses passenger and nginx to serve
[20:16:54] big_reggie: how do you guys keep state consistent for tests that rely on fixtures (e.g. what if the fixtures a test relies on gets changed in the future?)
[20:49:38] big_reggie: fryguy: my apologies, i mean for example if I look at the YAML fixture files, see they have some structure, then a year later another developer comes in and changes those YAML files
[20:55:16] fryguy: can you cite an example? I'd like to see a situation with well-written tests that would behave this way
[20:59:03] big_reggie: fryguy: any test that checks that there are no associations under specific conditions between two models (when you expect assocations in the fixtures to exist)
[21:03:17] big_reggie: fryguy: e.g. you want to test some User can't access some of his Books without a premium subscription, so a test that calling user.getBooks returns an empty array under those conditions
[21:05:23] fryguy: here's some more information based on the theory of the testing pyramid: https://martinfowler.com/articles/practical-test-pyramid.html#WhatToTest
[21:05:25] big_reggie: so really you would need to make sure you are using the same user in both unit tests
[21:09:12] big_reggie: i see now, my mistake was more dealing with negative assertions (which need positive assertion tests coupled to them)
[23:16:02] sandroqz: hi guys, I need to upload a CSV file and then show a preview of the data. if the user hit confirm then the data should be persisted to the db otherwise the data is cleaned up. what is the best way to do this? thanks.
[23:22:23] fryguy: guess it depends on what is necessary business logic wise to generate the preview
[23:23:24] fryguy: if it's just a reification of the CSV file, then upload the CSV to some sort of centralized object store like S3. if you need to do a lot of processing, consider doing the same thing if you can stand the request overhead, or put the work into a background job with a status checker. alternatively create a temporary table to store the data.
[23:30:02] sandroqz: fryguy, i just need to show the CSV data to the user. if he/she hits enter then the data should be persisted.
[23:31:51] sandroqz: unfortunately i can't upload to S3... i can upload to my server but after the data is persisted i need to remove the file