« Back to channel list

#RubyOnRails - 18 December 2018

« Back 1 day Forward 1 day »
[00:06:03] wethu: has joined #RubyOnRails
[00:13:32] Cork: has joined #RubyOnRails
[00:51:17] EminenceHC: has joined #RubyOnRails
[00:52:50] sirensari2: has joined #RubyOnRails
[01:00:56] sevenseacat: has joined #RubyOnRails
[01:04:08] blackmesa: has joined #RubyOnRails
[01:12:28] jottr: has joined #RubyOnRails
[01:31:53] Puffball: has joined #RubyOnRails
[01:34:10] mostlybadfly: has joined #RubyOnRails
[01:40:17] orbyt_: has joined #RubyOnRails
[01:46:45] EXCHGR: has joined #RubyOnRails
[02:03:28] cnsvc_: has joined #RubyOnRails
[02:41:54] MasterAsia: has joined #RubyOnRails
[02:42:31] sirensari__: has joined #RubyOnRails
[02:43:19] ariedler: has joined #RubyOnRails
[03:19:43] jottr: has joined #RubyOnRails
[03:58:17] cnsvc_: has joined #RubyOnRails
[04:06:46] CBebop: has joined #RubyOnRails
[04:09:50] braincrash: has joined #RubyOnRails
[04:16:37] roshanavand1: has joined #RubyOnRails
[04:39:05] roshanavand: has joined #RubyOnRails
[04:54:10] darkhanb: has joined #RubyOnRails
[05:10:01] Exuma: has joined #RubyOnRails
[05:29:08] jottr: has joined #RubyOnRails
[05:41:13] kapil____: has joined #RubyOnRails
[05:45:11] gambl0re: has joined #RubyOnRails
[06:01:06] cgfbee: has joined #RubyOnRails
[06:04:32] conta: has joined #RubyOnRails
[06:13:27] uks: has joined #RubyOnRails
[06:14:13] uks: has joined #RubyOnRails
[06:33:30] Exuma: has joined #RubyOnRails
[06:39:31] endemic: has joined #RubyOnRails
[06:44:09] gambl0r3: has joined #RubyOnRails
[06:46:39] reber: has joined #RubyOnRails
[06:51:21] za1b1tsu: has joined #RubyOnRails
[07:27:23] _aeris: has joined #RubyOnRails
[07:38:30] jottr: has joined #RubyOnRails
[07:47:17] reber: has joined #RubyOnRails
[08:07:59] MasterAsia: has joined #RubyOnRails
[08:12:42] srinidhi: has joined #RubyOnRails
[09:13:59] blackmesa: has joined #RubyOnRails
[09:18:07] blackmesa1: has joined #RubyOnRails
[09:31:35] jottr: has joined #RubyOnRails
[09:39:44] deathwishdave: has joined #RubyOnRails
[09:48:48] lxsameer: has joined #RubyOnRails
[09:52:33] IGnorAND: https://apidock.com/rails/ActiveRecord/QueryMethods/distinct <- based on what does the distinction happen (if I have more columns I want to select)?
[09:52:57] adac: has joined #RubyOnRails
[09:54:20] adac: my_array = [[1,2], [3,4], [5,6]] can I validate such an array in the model in a way that only every second element of the arrays in the array is evaluated?
[09:54:35] adac: so only 2,4,6 should be vaidated
[09:56:28] cnsvc_: has joined #RubyOnRails
[09:59:45] tbuehlmann: IGnorAND: distinct uses all the columns you're selecting
[10:11:34] tbuehlmann: adac: write a custom validation
[10:12:44] adac: tbuehlmann, by that you mean I should write a method that returns only a one dimensional array that can be checken with inclusion in or?
[10:13:30] IGnorAND: @tbuehlmann I have a list of requests of people that have an insurance (no list of people). I'd like a list of all unique people with a (in)valid insurance. I was hoping distinct could help
[10:15:46] IGnorAND: select distinct on (person_id), first_name, last_name where expire_date> Date.now or something similar
[10:17:02] tbuehlmann: adac: you didn't write anything about an inclusion validation, but yes, that's one way to do it
[10:18:37] adac: tbuehlmann, yes I meant a model validation like it wokrs with an one dimensional array: validates :some_uri, inclusion: { in: :valid_some_uri }, allow_blank: true
[10:19:05] tbuehlmann: IGnorAND: ordering by (in)valid insurance and using DISTINCT ON should work. you can't use the distinct method for that, though, as that uses DISTINCT and not DISTINCT ON. you'll have to use something like .select('DISTINCT ON (foo) *') (or group, which works similarly)
[10:19:05] adac: but instead of this array having validated my example array from above
[10:20:52] tbuehlmann: adac: you want some kind of inclusion validation but for multiple (but not all) values from an array?
[10:21:11] IGnorAND: tbuehlmann: I did that' but then things like count start to break
[10:22:21] adac: tbuehlmann, yes that is what I would need. actually i would need inclusion validation from an array that holds array pairs, and I only want to evaluate every second enty of the value pair
[10:23:25] tbuehlmann: write a custom validation then
[10:24:37] adac: kk thanks.
[10:27:53] _aeris: has joined #RubyOnRails
[10:33:35] DaniG2k: has joined #RubyOnRails
[10:33:55] DaniG2k: hello all, I'm trying to get Carrierwave to upload image versions to an AWS S3 bucket but it doesn't seem to work
[10:34:02] DaniG2k: I can get the main image to upload just fine
[10:34:10] DaniG2k: but the thumbnail version does not get uploaded
[10:34:44] DaniG2k: I've Googled it a lot but can't seem to find any info on how to save the different versions
[10:50:21] Ergo: has joined #RubyOnRails
[10:57:11] roshanavand: has joined #RubyOnRails
[11:05:15] srinidhi: has joined #RubyOnRails
[11:17:06] Jervis_: has joined #RubyOnRails
[11:37:46] wethu: has joined #RubyOnRails
[11:40:46] ellcs: has joined #RubyOnRails
[11:55:26] ariedler: has joined #RubyOnRails
[11:55:37] sevenseacat: what does your code look like atm?
[11:56:25] DaniG2k: sevenseacat: thanks for the response. I've posted the code on SO: https://stackoverflow.com/questions/53823063/rails-4-uploading-carrierwave-generated-image-versions-to-aws-s3?noredirect=1#comment94510702_53823063
[11:56:29] DaniG2k: it's super basic
[11:56:46] DaniG2k: main image is being uploaded, thumb doesn't seem to be uploaded :/
[11:57:01] ariedler: has joined #RubyOnRails
[11:57:41] sevenseacat: do you have minimagick on your production server?
[11:58:45] DaniG2k: sevenseacat: actually I just was testing by setting if Rails.env.production? || Rails.env.development?
[11:58:59] DaniG2k: so that it was using fog in development to see if the images got uploaded to AWS S3
[11:59:04] DaniG2k: the main one does, so that works
[11:59:14] DaniG2k: it's the thumb that doesn't seem to get uploaded
[11:59:27] sevenseacat: is the main one at 800 wide?
[11:59:40] DaniG2k: thumb is 200 wide
[11:59:45] sevenseacat: no, when uploaded
[12:00:05] DaniG2k: hmm good point
[12:00:07] sevenseacat: what version of carrierwave are you using?
[12:01:30] DaniG2k: im using Dropzone on the frontend, so the images get resized on the client side before passing to Rails. I have the resize on Dropzone set to 800px
[12:01:45] DaniG2k: so it arrives already with a width of 800 when it reaches the Rails controller
[12:02:29] sevenseacat: ok maybe change the uploader to something that isnt 800, to make sure its working?
[12:10:39] DaniG2k: sevenseacat: yep carrierwave is performing the main resize
[12:11:00] DaniG2k: i uploaded an image that was 1600 wide, set Dropzone to resize to 1000, and the uploaded image is 800px
[12:11:07] DaniG2k: so that's working
[12:11:28] DaniG2k: ohhhhh jeez
[12:11:30] DaniG2k: i found the error
[12:11:30] sevenseacat: next question is,areyou looking in the right place on s3?
[12:11:43] DaniG2k: yep the url I was returning was incorrect
[12:11:50] sevenseacat: heh, it happens
[12:11:52] DaniG2k: thanks for helping me reason through that one >.< I feel dumb now
[12:13:36] DaniG2k: so the issue is actually the following: i am serving the images throgh a controller (in order to control which users have permission to see the images and which don't)
[12:13:57] DaniG2k: the show method returns `send_file my_image.file.path, disposition: :inline`
[12:14:09] DaniG2k: the thumb method returns `send_file my_image.file.thumb.path, disposition: :inline`
[12:14:29] DaniG2k: which works fine when storage is :file
[12:14:50] DaniG2k: for :fog storage I probably need to return the url, not path
[12:14:53] DaniG2k: I think that's it
[12:15:09] sevenseacat: yeah you'll need to handle things diffrently
[12:15:46] DTZUZO: has joined #RubyOnRails
[12:17:59] kapil____: has joined #RubyOnRails
[12:20:46] DaniG2k: sevenseacat: you've been in this channel for ages. I respect your faithfulness to Rails
[12:20:57] sevenseacat: been a few years now, yeah
[12:21:05] DaniG2k: what do you do? full-time dev?
[12:21:29] DaniG2k: heheh awesome
[12:35:57] EminenceHC: has joined #RubyOnRails
[12:46:04] ellcs: has joined #RubyOnRails
[12:50:46] reber: has joined #RubyOnRails
[12:51:59] uks: has joined #RubyOnRails
[12:57:53] cnsvc_: has joined #RubyOnRails
[12:59:47] uks: has joined #RubyOnRails
[13:02:16] mostlybadfly: has joined #RubyOnRails
[13:18:11] GodFather: has joined #RubyOnRails
[13:21:24] lxsameer: has joined #RubyOnRails
[13:26:16] blackmesa1: has joined #RubyOnRails
[13:38:51] kidPalooma: has joined #RubyOnRails
[13:40:32] kidPalooma: Hello, how do I set default database timezone with Rails? I want my app and database to be synchronized on UTC timezone but my local db is acting up and I don't want this to happen in other stages. Best solution for me would be to set database timezone along with the database schema
[13:47:29] tbuehlmann: kidPalooma: rails converts times to UTC when inserting/updating/selecting, so all you times in the database are UTC. now you can setup a default timezone which rails will use for conversions in your config/application.rb: config.time_zone = 'Berlin'
[13:51:41] phon: has joined #RubyOnRails
[13:53:54] kidPalooma: tbuehlmann: I have configured Rails to use UTC, I also have ran a migration with this option: "t.datetime :renewed_at, null: false, default: -> { 'CURRENT_TIMESTAMP' }". Now, the value that is CURRENT_TIMESTAMP at the time of the insertion is up to the database, I want control over what timezone the database uses when calling "CURRENT_TIMESTAMP"
[13:55:34] kidPalooma: In my case, on my local machine that value is the Local time (the one that I see in my operating system). I'd like to set it with Rails so that whenever my app connects to a database (or migrates, rather), it sets the correct UTC timezone on the db
[13:56:04] kidPalooma: possibile? impossible?
[13:56:38] lxsameer: has joined #RubyOnRails
[13:58:47] kidPalooma: or, alternatively, set the default value for that field using a rails function rather than a (in my case) mySql function
[13:59:12] tbuehlmann: sure, just set the value when creating/updating a record
[13:59:13] kidPalooma: I have tried with mySql's UTC_TIMESTAMP() but the migration won't run
[13:59:41] kidPalooma: tbuehlmann: this rids me of just this instance of the problem
[13:59:56] kidPalooma: I want to rely on the database having UTC as default timezone
[13:59:58] tbuehlmann: you should be able to call YourModel.update_all(renewed_at: Time.current)
[14:00:52] tbuehlmann: um, well, I guess you can configure that in mysql?
[14:01:21] kidPalooma: tbuehlmann: yes, but do I have a way to do it through Rails?
[14:03:19] tbuehlmann: there are some options it seems: https://stackoverflow.com/a/19069310/384293
[14:03:37] tbuehlmann: connecting with a prepared uri string using serverTimezone=UTC could work as well
[14:05:22] alan_w: has joined #RubyOnRails
[14:05:43] kidPalooma: tbuehlmann: ok, I'm looking for the function that does this in Rails
[14:06:30] tbuehlmann: I don't think there is one, but you can send raw sql to your database
[14:15:15] krawchyk: has joined #RubyOnRails
[14:25:15] dslegends: has joined #RubyOnRails
[14:38:20] arcaos: has joined #RubyOnRails
[14:45:42] context: kidPalooma: rails always stores timestamps as UTC in the database
[14:46:53] kidPalooma: tbuehlmann: I solved it, I have set a variable in my database.yml file, now both Rails and mySql use UTC
[14:47:00] context: kidPalooma: you can set the tz on a per-request basis if you want users to see their specific timezone ? if thats what you mean
[14:47:11] context: but you do _not_ want to store values in different timezones.
[14:47:18] kidPalooma: using the somewhat less documented 'variables' option
[14:47:45] kidPalooma: context: I want any database my app connects to to use UTC
[14:48:05] context: yeah, rails stores all values as utc
[14:48:26] kidPalooma: context: yes, I want the database to also do that when it uses its own time functions
[14:49:05] kidPalooma: you can do something like : t.datetime :renewed_at, null: false, default: -> { 'CURRENT_TIMESTAMP' } in a migration but I was lacking control over that CURRENT_TIMESTAMP function
[14:49:18] kidPalooma: that date is not set by Rails, hence the issue
[14:51:34] context: ahh. id probably do that as a callback, i imagine you have a callback that updates it, but anywho :-/ glad you got it
[15:04:06] dbugger_: has joined #RubyOnRails
[15:06:26] beholders_eye: has joined #RubyOnRails
[15:17:25] agent_white: has joined #RubyOnRails
[15:21:29] lexileo: has joined #RubyOnRails
[15:27:42] cnsvc_: has joined #RubyOnRails
[15:35:56] kidPalooma: context: yes, I was about to do a callback but that meant repeating it whenever I wanted to do it again, this method allows me to take mysql time zone for granted
[15:36:23] kidPalooma: and I don't need to write/mantain any extra code
[16:17:22] tycoon177: is there a built-in way to load just the last association in a has_many in activerecord?
[16:28:48] tubbo: tycoon177: `foo.bars.last`?
[16:31:20] chouhoulis: has joined #RubyOnRails
[16:33:34] tycoon177: tubbo: I was hoping to preload it, sorry. It's for a collection of rows
[16:34:19] conta: has joined #RubyOnRails
[16:34:51] tubbo: tycoon177: nothing that i know of, might be able to do it with a `joins` though
[16:35:49] chouhoulis: has joined #RubyOnRails
[16:37:00] conta1: has joined #RubyOnRails
[16:37:48] tycoon177: thanks tubbo! I ended up just doing an `includes` with some conditions in the where clause that pared it down well enough that i'm not worried about performance impacts
[16:48:02] ellcs: has joined #RubyOnRails
[17:01:07] kapil____: has joined #RubyOnRails
[17:07:56] uks: has joined #RubyOnRails
[17:10:21] samort7: has joined #RubyOnRails
[17:12:45] krawchyk: has joined #RubyOnRails
[17:13:01] LambdaSource: has joined #RubyOnRails
[17:20:36] maryo: has joined #RubyOnRails
[17:32:51] GodFather: has joined #RubyOnRails
[17:42:54] karadshf: has joined #RubyOnRails
[17:43:44] reber: has joined #RubyOnRails
[17:46:21] CGibsonmm: has joined #RubyOnRails
[17:47:02] darkhanb: has joined #RubyOnRails
[17:49:27] CGibsonmm: I am running into issues with rails 5.2 ActiveStorage some images after they are uploaded they are being displayed sideways, from what I see active storage is not saving anything other than a height x width of images and has no orientation data saved, I am also having issues trying to attach minimagic to any part of the blob that is saved with rails
[17:55:13] CGibsonmm: This seems to be the only documentation on exif and activestorage https://api.rubyonrails.org/classes/ActiveStorage/Analyzer/ImageAnalyzer.html
[17:56:44] orbyt_: has joined #RubyOnRails
[17:58:05] cnsvc_: has joined #RubyOnRails
[18:23:25] Saukk: has joined #RubyOnRails
[18:30:19] reber: has joined #RubyOnRails
[18:36:52] dslegends: has joined #RubyOnRails
[18:41:47] guillec: has joined #RubyOnRails
[18:47:38] CGibsonmm: has joined #RubyOnRails
[18:50:55] MasterAsia: has joined #RubyOnRails
[18:53:23] LambdaSource: has joined #RubyOnRails
[19:00:50] _aeris_: has joined #RubyOnRails
[19:20:50] thumby: has joined #RubyOnRails
[19:21:02] Puffball: has joined #RubyOnRails
[19:22:09] thumby: Hi, I've got an issue trying to create a new Rails app with the --api flag. Is this the right place to ask about it?
[19:31:16] thumby: has joined #RubyOnRails
[19:32:23] thumby: Hi, I've got an issue trying to create a new Rails app with the --api flag. Is this the right place to ask about it?
[19:40:07] conta: has joined #RubyOnRails
[19:53:40] gambl0r3: has joined #RubyOnRails
[19:59:34] Fernando-Basso: has joined #RubyOnRails
[20:00:37] MasterAsia: has joined #RubyOnRails
[20:04:32] _aeris: has joined #RubyOnRails
[20:24:49] GodFather: has joined #RubyOnRails
[20:44:06] sonOfRa: has joined #RubyOnRails
[21:06:38] kapil____: has joined #RubyOnRails
[21:24:26] tubbo: anyone here running headless chrome on docker? we're using the options `--headless --disable-gpu --disable-popup-blocking --window-size=1400,1400 --no-sandbox`, and getting the error "unknown error: DevToolsActivePort file doesn't exist"
[21:24:59] tubbo: full error: https://gist.github.com/tubbo/df68dd4fc9f60afc26a4f47684e38f49
[21:25:08] tubbo: running Chrome 71 afaict
[21:29:35] MasterAsia: has joined #RubyOnRails
[21:44:33] cnsvc_: has joined #RubyOnRails
[22:04:21] wethu: has joined #RubyOnRails
[22:22:59] ellcs: has joined #RubyOnRails
[22:31:30] Exuma: has joined #RubyOnRails
[22:31:35] lxsameer: has joined #RubyOnRails
[22:57:02] Inside: has joined #RubyOnRails
[22:57:17] Inside: ACTION sighs c_C
[22:57:31] Inside: I think it's time to bite the bullet and jump to rails 5.0
[23:00:01] sirensari2: has joined #RubyOnRails
[23:17:48] Jervis_: has joined #RubyOnRails
[23:36:04] CGibsonmm: has joined #RubyOnRails
[23:47:24] bambanx: has joined #RubyOnRails
[23:47:44] RiPuk: has joined #RubyOnRails
[23:59:38] Inside: I give upo
[23:59:41] Inside: gonna go farm emus instead