« Back to channel list

#RubyOnRails - 12 September 2018

« Back 1 day Forward 1 day »
[00:06:04] bijan_: has joined #RubyOnRails
[00:07:31] alexertech: has joined #RubyOnRails
[00:11:23] bijan_: has joined #RubyOnRails
[00:19:24] bijan_: has joined #RubyOnRails
[00:22:52] cagomez: has joined #RubyOnRails
[00:25:06] jottr: has joined #RubyOnRails
[00:28:11] DTZUZO: has joined #RubyOnRails
[00:28:37] bijan_: has joined #RubyOnRails
[00:32:37] bijan__: has joined #RubyOnRails
[00:35:05] bijan_: has joined #RubyOnRails
[00:39:22] chouhoulis: has joined #RubyOnRails
[00:40:31] chouhoulis: has joined #RubyOnRails
[00:50:46] MasterAsia: has joined #RubyOnRails
[00:51:12] MasterAsia: It looks like there is no difference between a sign & encrypted cookie from a session (that uses the cookiestore)
[00:51:23] MasterAsia: is that right?
[00:53:18] bijan_: has joined #RubyOnRails
[00:55:48] bijan__: has joined #RubyOnRails
[00:57:24] advorak: has joined #RubyOnRails
[00:59:58] advorak: hi there. How do I add a 'get' to a resource from outside the resource definition? My code is here: https://gist.github.com/advorak/e2caf673189ffd3d93cf3b06ab23b19c
[01:07:11] lxsameer: has joined #RubyOnRails
[01:07:19] bijan_: has joined #RubyOnRails
[01:07:34] sevenseacat: has joined #RubyOnRails
[01:08:01] Dimik: has joined #RubyOnRails
[01:11:54] brandoncc: has joined #RubyOnRails
[01:14:48] orbyt_: has joined #RubyOnRails
[01:18:07] bijan_: has joined #RubyOnRails
[01:22:41] NeoHamled: advorak: would this work? https://gist.github.com/Hamled/29cd526eb6d1d152338692d932846244
[01:28:40] bijan_: has joined #RubyOnRails
[01:33:20] bijan__: has joined #RubyOnRails
[01:43:57] bijan_: has joined #RubyOnRails
[01:44:36] advorak: neohamled, I'm probably trying to do something that isn't liked by rails/rest by omitting the "/definitions" portion of the url, correct?
[01:46:52] NeoHamled: I'm not sure I have enough information to say if it's restful or not, if definitions, flashcards, multichoice, and type are all separate resources then they shouldn't be nested, so your approach is correct in that regard
[01:48:24] NeoHamled: and if you want all of the actions to be within the definitions controller, that's probably not following Rails' conventions, but it should be fine. I would do: https://gist.github.com/Hamled/29cd526eb6d1d152338692d932846244 possibly?
[01:53:05] NeoHamled: oh the link is the same but I've updated the file contents, sorry if that was confusing
[01:53:10] ivanskie: has joined #RubyOnRails
[01:55:08] duderonomy: has joined #RubyOnRails
[01:55:11] chouhoulis: has joined #RubyOnRails
[01:55:12] bijan_: has joined #RubyOnRails
[01:56:56] advorak: NeoHamled: yes! that's what I am looking for. thanks.
[01:57:12] NeoHamled: you're welcome
[01:57:26] advorak: I use rails intermittently to solve problems .. I perfect routes .. then I don't use rails .. then I forget about them .. and then I perfect them again :-)
[01:58:11] cagomez: has joined #RubyOnRails
[02:05:11] ivanskie: has joined #RubyOnRails
[02:06:10] bijan_: has joined #RubyOnRails
[02:12:14] bijan_: has joined #RubyOnRails
[02:16:08] samort7: has joined #RubyOnRails
[02:16:57] samort7: Anyone awake?
[02:22:57] samort7: I have a really noobish question about how forms work: https://codeshare.io/2BjAQK
[02:23:13] samort7: Just not sure why we create a new user object twice
[02:24:20] sevenseacat: in the new and create actions?
[02:24:42] sevenseacat: ok so the new action is the page that renders the form, right
[02:25:02] samort7: Right. So why do we need a user object at all, at that point?
[02:25:33] NeoHamled: it allows form_for to generate a form with certain things customized to the model
[02:25:40] NeoHamled: in this case
[02:25:45] sevenseacat: when you submit the form, all that gets passed to the server is the data that was on the form - you can see that in your development.log
[02:25:47] jottr: has joined #RubyOnRails
[02:25:50] i8igmac: has joined #RubyOnRails
[02:26:16] i8igmac: any one use ace editor with rails application
[02:26:19] samort7: sevenseacat: right - form_for creates a hash called user that contains all the entries, right?
[02:26:46] samort7: and that hash exists inside params, I think?
[02:26:52] sevenseacat: well in this case you have fields for name, email, password and password confirmation so thatswhat you get in your params
[02:28:44] samort7: ok, and then the form passes that data back to create, where it calls the user_params method to filter it, and passes those filter results to a new user object
[02:29:28] kotepillar_: has joined #RubyOnRails
[02:29:44] samort7: I guess I am still trying to understand what NeoHamled was saying - how the @user variable in new interacts with the form
[02:30:38] sevenseacat: rails will do things like pull the values of fields for the values of the form elements
[02:30:39] i8igmac: im not sure if i should use ace-rails-ap gem or the original git repo github.com/ajaxorg/ace-builds
[02:30:58] sevenseacat: eg. if you set the @user.email in the new action, it would be prefilled on the form
[02:31:27] sevenseacat: some of it is just niceness so the same form can easily be used for new/create/edit/update
[02:31:57] NeoHamled: it can inspect the @user object and figure out if you are creating a new one or updating an existing one
[02:32:25] sevenseacat: aye, and set the URL that the form submits to appropriately (if following rails resourceful conventions)
[02:32:42] samort7: oh that's pretty neat. Another "rails magic" moment it seems
[02:32:56] NeoHamled: one of the more magic parts of rails I'd say
[02:34:39] samort7: sevenseacat: I just tried that @user.email thing - that's pretty cool!!!
[02:37:50] sevenseacat: if you had something like a form for a user to edit their profile - you could just do form_for @user and all of the form fields would be filled out with the data from that user
[02:38:40] samort7: sevenseacat: oooh! That makes tons of sense!
[02:50:00] i8igmac: could some one provide help with ace code editor. i hope to run this editor and make changes to the currently running rails project with a tree source view of the directory structure
[02:52:02] bijan_: has joined #RubyOnRails
[03:00:43] cagomez_: has joined #RubyOnRails
[03:01:10] ariedler: has joined #RubyOnRails
[03:03:18] bijan_: has joined #RubyOnRails
[03:04:10] dar123: has joined #RubyOnRails
[03:05:28] dtzuzu: has joined #RubyOnRails
[03:07:53] lxsameer: has joined #RubyOnRails
[03:11:12] braincrash: has joined #RubyOnRails
[03:14:37] bijan_: has joined #RubyOnRails
[03:20:09] i8igmac: are there any ide's that i can install in my rails app to provide remote access to the project from a android phone
[03:22:23] dar123: has joined #RubyOnRails
[03:22:49] apeiros: has joined #RubyOnRails
[03:25:29] bijan_: has joined #RubyOnRails
[03:35:43] bijan_: has joined #RubyOnRails
[04:15:34] bijan_: has joined #RubyOnRails
[04:26:32] bijan_: has joined #RubyOnRails
[04:26:43] jottr: has joined #RubyOnRails
[04:38:15] bijan_: has joined #RubyOnRails
[04:49:20] bijan_: has joined #RubyOnRails
[04:52:04] Technodrome: has joined #RubyOnRails
[05:00:56] bijan_: has joined #RubyOnRails
[05:06:19] MoritaShinobu: has joined #RubyOnRails
[05:11:32] Sonja: has joined #RubyOnRails
[05:12:07] bijan_: has joined #RubyOnRails
[05:12:15] Sonja: Does Rails have a method that minifies or compresses an HTML file, and can I use it in Ruby code independently of Rails?
[05:13:00] reber: has joined #RubyOnRails
[05:23:18] bijan_: has joined #RubyOnRails
[05:30:00] kotepillar_: has joined #RubyOnRails
[05:32:04] srinidhi: has joined #RubyOnRails
[05:33:49] bijan_: has joined #RubyOnRails
[05:37:27] Linuus: has joined #RubyOnRails
[05:45:05] bijan_: has joined #RubyOnRails
[05:56:30] bijan_: has joined #RubyOnRails
[06:01:46] nemesit: has joined #RubyOnRails
[06:07:20] bijan_: has joined #RubyOnRails
[06:09:54] MoritaShinobu: has joined #RubyOnRails
[06:15:37] yasser_: has joined #RubyOnRails
[06:16:12] yasser_: hey guys rails plugin for vim does not work properly for me
[06:16:28] yasser_: :find command only searches through .rb files
[06:16:48] yasser_: i'd prefer that it searches through my entire project
[06:16:58] yasser_: including yml and other files
[06:17:07] yasser_: anybody used rails plugin here?
[06:18:43] bijan_: has joined #RubyOnRails
[06:20:58] za1b1tsu: has joined #RubyOnRails
[06:27:35] jottr: has joined #RubyOnRails
[06:29:58] bijan_: has joined #RubyOnRails
[06:31:05] dionysus69: Hey all, I have heard in past that modifying params hash in place was not gonna be possible soon, I don't know if that soon is already here but anyway I want to do the following, I am passing some parent model attribute instead of an ID, using IDs in my scenario doesnt make sense, so I want to select IDs before I insert params hash in Model.new, so how do I go about it?
[06:31:15] bijan_: has joined #RubyOnRails
[06:31:42] eckhardt_: has joined #RubyOnRails
[06:45:41] bijan_: has joined #RubyOnRails
[06:55:37] bijan_: has joined #RubyOnRails
[06:57:07] moei: has joined #RubyOnRails
[06:59:30] kotepillar_: has joined #RubyOnRails
[07:03:02] sandstrom: has joined #RubyOnRails
[07:07:17] MoritaShinobu: has joined #RubyOnRails
[07:10:20] Technodrome: has joined #RubyOnRails
[07:15:47] kotepillar_: has joined #RubyOnRails
[07:16:27] kotepillar_: has joined #RubyOnRails
[07:20:50] ur5us: has joined #RubyOnRails
[07:25:04] armyriad: has joined #RubyOnRails
[07:26:54] armyriad: has joined #RubyOnRails
[07:29:43] bijan_: has joined #RubyOnRails
[07:32:27] fourcolors: has joined #RubyOnRails
[07:32:56] fourcolors: Does anyone know a good way to duplicate an ActiveRecord Model that has an ActiveStorage attachment associated with it?
[07:34:15] bijan__: has joined #RubyOnRails
[07:39:52] bijan_: has joined #RubyOnRails
[07:43:50] bijan_: has joined #RubyOnRails
[07:48:11] bijan_: has joined #RubyOnRails
[07:52:29] sandstrom: has joined #RubyOnRails
[07:59:41] lxsameer: has joined #RubyOnRails
[08:01:21] bijan_: has joined #RubyOnRails
[08:01:40] psychoslave: has joined #RubyOnRails
[08:09:31] mikecmpbll: has joined #RubyOnRails
[08:12:33] bijan_: has joined #RubyOnRails
[08:15:18] bijan__: has joined #RubyOnRails
[08:17:07] v01d4lph4: has joined #RubyOnRails
[08:20:34] bijan_: has joined #RubyOnRails
[08:22:17] bijan_: has joined #RubyOnRails
[08:28:23] jottr: has joined #RubyOnRails
[08:31:03] bijan_: has joined #RubyOnRails
[08:35:14] bijan_: has joined #RubyOnRails
[08:37:58] bijan__: has joined #RubyOnRails
[08:58:33] psychoslave: has joined #RubyOnRails
[09:03:36] ariedler: has joined #RubyOnRails
[09:08:55] MoritaShinobu: has joined #RubyOnRails
[09:16:28] morfin: has joined #RubyOnRails
[09:16:43] morfin: can i somehow use I18n.t() with certain locale?
[09:17:14] morfin: t('string', locale: :ru)?
[09:18:08] tbuehlmann: morfin: exactly like that. haven't you tried?
[09:29:04] bijan_: has joined #RubyOnRails
[09:33:25] bijan_: has joined #RubyOnRails
[09:39:18] bijan_: has joined #RubyOnRails
[09:55:48] lexileo: has joined #RubyOnRails
[10:18:24] bijan_: has joined #RubyOnRails
[10:22:20] bijan__: has joined #RubyOnRails
[10:26:56] bijan_: has joined #RubyOnRails
[10:31:16] bijan_: has joined #RubyOnRails
[10:32:35] MoritaShinobu: has joined #RubyOnRails
[10:33:10] bijan__: has joined #RubyOnRails
[10:38:11] bijan_: has joined #RubyOnRails
[10:53:13] lankanmon: has joined #RubyOnRails
[10:54:46] za1b1tsu: has joined #RubyOnRails
[10:55:07] ariedler: has joined #RubyOnRails
[10:57:13] za1b1tsu: is it possible to create with nested attributes children of a child?
[10:59:23] bijan_: has joined #RubyOnRails
[11:00:16] dionysus69: za1b1tsu: yes, it doesn't have constaint on dimension of a param hash
[11:01:52] GodFather: has joined #RubyOnRails
[11:02:26] DTZUZO: has joined #RubyOnRails
[11:03:39] bijan__: has joined #RubyOnRails
[11:08:00] bijan_: has joined #RubyOnRails
[11:11:23] kotepillar_: has joined #RubyOnRails
[11:12:14] bijan_: has joined #RubyOnRails
[11:20:57] bijan_: has joined #RubyOnRails
[11:25:09] bijan__: has joined #RubyOnRails
[11:28:30] MoritaShinobu: has joined #RubyOnRails
[11:29:47] bijan_: has joined #RubyOnRails
[11:33:18] kapil___: has joined #RubyOnRails
[11:38:04] bijan_: has joined #RubyOnRails
[11:46:41] bijan_: has joined #RubyOnRails
[11:50:54] bijan_: has joined #RubyOnRails
[11:55:12] bijan_: has joined #RubyOnRails
[11:56:40] psychoslave: has joined #RubyOnRails
[11:59:34] bijan__: has joined #RubyOnRails
[12:16:28] bijan_: has joined #RubyOnRails
[12:25:42] bijan_: has joined #RubyOnRails
[12:29:34] bijan__: has joined #RubyOnRails
[12:38:01] kotepillar_: has joined #RubyOnRails
[12:41:08] dblessing: has joined #RubyOnRails
[12:42:07] bijan_: has joined #RubyOnRails
[12:43:23] DoubleMalt: has joined #RubyOnRails
[12:46:56] Tempesta: has joined #RubyOnRails
[12:47:09] LightStalker: has joined #RubyOnRails
[12:48:09] cpinto: has joined #RubyOnRails
[12:50:41] cpinto: Can anyone give me some pointers to improve this code? https://gist.github.com/cpinto/b01fc9e9a7b6f41ee5815d2e2ca4e9f0
[12:51:18] cpinto: I'm looking to load the attachments and the blobs with one query. the current implementation hits the database twice.
[12:51:18] bijan_: has joined #RubyOnRails
[12:51:23] cpinto: thanks in advance
[12:54:41] knight33: has joined #RubyOnRails
[12:55:18] bijan__: has joined #RubyOnRails
[12:59:57] bijan_: has joined #RubyOnRails
[13:05:33] cpinto: has left #RubyOnRails: ()
[13:08:03] cpinto: has joined #RubyOnRails
[13:10:28] bijan_: has joined #RubyOnRails
[13:17:40] MoritaShinobu: has joined #RubyOnRails
[13:25:43] bijan_: has joined #RubyOnRails
[13:26:07] sandstrom: has joined #RubyOnRails
[13:29:54] sevenseacat: has joined #RubyOnRails
[13:53:49] IanMalcolm: has joined #RubyOnRails
[14:11:33] work_: has joined #RubyOnRails
[14:20:28] safetypin: has joined #RubyOnRails
[14:26:05] dblessing: has joined #RubyOnRails
[14:35:26] Dbugger: has joined #RubyOnRails
[14:45:42] cagomez: has joined #RubyOnRails
[14:56:29] desperek: has joined #RubyOnRails
[14:57:54] endemic: has joined #RubyOnRails
[15:15:45] endemic_: has joined #RubyOnRails
[15:19:32] IanMalcolm: has joined #RubyOnRails
[15:20:22] endemic_: has joined #RubyOnRails
[15:33:34] conta1: has joined #RubyOnRails
[15:46:21] rikkipitt: has joined #RubyOnRails
[15:47:32] rikkipitt: hey folks, i'm using a simpledelegator for a "Post", what's the best way to decorate child comments is a similar fashion?
[15:48:09] rikkipitt: e.g. @post = PostDecorator.new(post)
[15:48:35] rikkipitt: but post loads child comments which I'd like to also decorate
[15:52:28] srinidhi: has joined #RubyOnRails
[15:52:42] sandstrom: has joined #RubyOnRails
[15:54:22] ivanskie: has joined #RubyOnRails
[15:57:58] jottr: has joined #RubyOnRails
[16:15:57] lxsameer: has joined #RubyOnRails
[16:16:50] dblessing: has joined #RubyOnRails
[16:18:27] za1b1tsu: with nested_attributes for children of a child I can update and delete, but I cannot create
[16:18:41] za1b1tsu: for the child of a child it asks for a child id
[16:19:02] za1b1tsu: *child-parent
[16:19:38] brandoncordell: has joined #RubyOnRails
[16:20:54] brandoncordell: I'm updating our application to Rails 5.2 and I'm having some issues. Running bin/update or any rails commands all output the two following messages before executing. The first message is: "This method is not allowed with this Ruby version. current: 2.5.1, allowed version: < 2.5.0"
[16:21:38] brandoncordell: I searched google and the only thing that came up was a source file in bootsnap, but the message is only similar, not exact. The other page that came up was a SO question but it wasn't the point of the question so no one mentioned it.
[16:21:54] brandoncordell: The second message I get is: "Warning: method `clone` already defined"
[16:22:48] orbyt_: has joined #RubyOnRails
[16:22:58] brandoncordell: Is there a way to run a stacktrace along with bin/update or similar commands?
[16:23:25] agent_white: has joined #RubyOnRails
[16:23:56] Linuus: has joined #RubyOnRails
[16:25:08] [Butch]: has joined #RubyOnRails
[16:25:58] lxsameer: has joined #RubyOnRails
[16:33:21] nme13: has joined #RubyOnRails
[16:34:09] nme13: Please I need some help with an app wich is in production mode
[16:34:34] nme13: I just had to modify a link, I made this with nano as I have access to SSH
[16:35:09] nme13: but I don't know how to "refresh" (I mean to refresh "server-side")
[16:36:01] nme13: The app use redis and is hosted on AWS, I didn't make the app myself
[16:36:04] lxsameer: has joined #RubyOnRails
[16:36:15] nme13: anyone could help me ? At least any idea ?
[16:37:49] IanMalcolm: has joined #RubyOnRails
[16:44:05] jottr: has joined #RubyOnRails
[16:46:00] lxsameer: has joined #RubyOnRails
[16:47:02] Aherin: has joined #RubyOnRails
[16:52:43] prettybTech: has joined #RubyOnRails
[16:55:57] lxsameer: has joined #RubyOnRails
[17:00:56] duderono_: has joined #RubyOnRails
[17:04:58] safetypin: has joined #RubyOnRails
[17:05:01] cagomez: has joined #RubyOnRails
[17:06:03] lxsameer: has joined #RubyOnRails
[17:08:51] onecaesar: has joined #RubyOnRails
[17:09:38] prettybTech: has joined #RubyOnRails
[17:15:56] lxsameer: has joined #RubyOnRails
[17:21:58] GodFather: has joined #RubyOnRails
[17:22:26] jottr: has joined #RubyOnRails
[17:24:13] Technodrome: has joined #RubyOnRails
[17:25:51] lxsameer: has joined #RubyOnRails
[17:26:12] charlielor: has joined #RubyOnRails
[17:26:39] charlielor: I kept getting this error Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development on my page.
[17:27:15] chouhoulis: has joined #RubyOnRails
[17:28:20] orbyt_: has joined #RubyOnRails
[17:28:22] charlielor: so I ran rails db:migrate RAILS_ENV=development and I got this error: https://kopy.io/uaulC
[17:29:25] desperek: has joined #RubyOnRails
[17:35:32] [Butch]: has joined #RubyOnRails
[17:35:59] lxsameer: has joined #RubyOnRails
[17:36:32] s2013: has joined #RubyOnRails
[17:36:51] s2013: which editor/ide do yall use?
[17:38:09] duderonomy: has joined #RubyOnRails
[17:45:59] lxsameer: has joined #RubyOnRails
[17:51:10] mikecmpbll: has joined #RubyOnRails
[17:52:39] kapil___: has joined #RubyOnRails
[17:56:05] lxsameer: has joined #RubyOnRails
[17:56:21] jottr: has joined #RubyOnRails
[17:56:22] blindMoe: has joined #RubyOnRails
[17:57:30] blindMoe: Has anyone ran into an issue with send_early_hints from rspec tests when upgrade to rails 5.2? I can't seem to figure out what is happening since it says it is trying to call it on an OpenStruct yet the request object in the test is what is should be
[18:00:32] charlielor: What does this error Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for: means?
[18:00:54] charlielor: I keeps running into this error when migrating db.
[18:06:00] lxsameer: has joined #RubyOnRails
[18:06:36] safetypin: has joined #RubyOnRails
[18:11:10] safetypin: has joined #RubyOnRails
[18:16:05] lxsameer: has joined #RubyOnRails
[18:22:17] hgost: has joined #RubyOnRails
[18:26:02] lxsameer: has joined #RubyOnRails
[18:45:40] lxsameer: has joined #RubyOnRails
[18:47:31] Aherin: has joined #RubyOnRails
[18:49:00] gmcintire: has joined #RubyOnRails
[18:50:37] segy: has joined #RubyOnRails
[18:51:52] safetypin: has joined #RubyOnRails
[18:55:52] lxsameer: has joined #RubyOnRails
[19:04:23] cpinto: has joined #RubyOnRails
[19:05:58] lxsameer: has joined #RubyOnRails
[19:07:51] eckhardt: has joined #RubyOnRails
[19:29:24] MrPunkin: has joined #RubyOnRails
[19:30:12] MrPunkin: How can I convert crazy unicode text into normal text? I have a string that is all \u000e\u000i stuff that I just want to work the same as if I ‘puts’ that data and it is rendered.
[19:31:18] T3RM1N41: has joined #RubyOnRails
[19:36:42] sameerynho: has joined #RubyOnRails
[19:43:53] defsdoor: has joined #RubyOnRails
[19:46:48] lunarkitty: has joined #RubyOnRails
[19:54:10] apeiros: MrPunkin: that doesn't look crazy. just utf-16be
[19:58:13] uksio: has joined #RubyOnRails
[19:58:47] sandstrom: has joined #RubyOnRails
[19:58:52] fragamus: has joined #RubyOnRails
[19:58:56] jottr: has joined #RubyOnRails
[20:00:16] fourcolors: has joined #RubyOnRails
[20:00:24] fourcolors: Hey everyone
[20:00:52] fourcolors: I have a question about rake task. When I run a very large rake task that could take a day or two, what is the best way to do that without taking down the server?
[20:01:03] fourcolors: Should I use a background job for this?
[20:05:40] cpinto: @fourcolors can't answer from a rails perspective, but from an ops perspective that's an affirmative. have you thought about the task's recovery as well? (ie. how to resume work if the task for some reason fails)
[20:07:26] Turnikov: has joined #RubyOnRails
[20:12:28] MrPunkin: apeiros: It’s getting used in hash keys (CSV parsing) and then fails to properly map to my other UTF-8 keys.
[20:12:54] apeiros: MrPunkin: well, it helps if you tell ruby that your input isn't utf-8.
[20:13:12] weaksauce: has joined #RubyOnRails
[20:13:37] apeiros: encodings can't be automatically detected (guessed at best), so unless you tell ruby which encoding it is, it'll assume it's the default (which in turn is usually utf-8)
[20:13:39] MrPunkin: Right, I did that. String is coming in as “ASCII-8BIT”. I’m using “encode” method to convert from that to UTF-8 while replacing invalid and undefined characters with nothing.
[20:13:52] apeiros: that's not how it works
[20:14:11] apeiros: encode tells ruby to map characters from one encoding to another.
[20:14:24] MrPunkin: Okay, so what’s the proper way to convert one encoding to another?
[20:14:25] apeiros: if your input *is* utf-8, there's no need to map characters.
[20:14:56] apeiros: wrong question. #encode is the right way to switch text from one encoding to another. but that's not what you need to do here.
[20:14:58] MrPunkin: The encoding of this email attachment’s body is coming up as ascii-8bit
[20:15:42] MrPunkin: #<Encoding:ASCII-8BIT>
[20:16:22] apeiros: in cases where you can, supply the encoding in your IO operation. in cases where you can't do that, force_encoding is used to tell ruby which encoding the string actually has.
[20:17:18] apeiros: encode -> map some bytes to some other bytes, so characters stay the same. force_encoding -> do not change any bytes, only set the .encoding flag so ruby knows which character certain bytes represent.
[20:17:31] apeiros: that stuff is text/string 101, you should learn it.
[20:17:39] MrPunkin: apeiros: I’m not missing the encoding flag on the input
[20:17:42] MrPunkin: so no need to force
[20:17:48] MrPunkin: it knows that it is ASCII-8BIT
[20:18:13] MrPunkin: I need to get that over to a usable format with invalid characters removed. So everything I read online said to use encode to do that.
[20:18:54] MrPunkin: I’m not guessing on the encoding for input, it’s already there from the Rails email attachment parser.
[20:19:31] apeiros: *sob*, if you know it better, why ask…
[20:20:01] MrPunkin: I don’t know it better, I’m admitting I don’t understand something, but your condecending assumptions that I’m just missing a huge part make it hard to actually get the help I need.
[20:20:17] prettybTech: has joined #RubyOnRails
[20:22:05] apeiros: you are missing a crucial part. your problem getting help is your attitude, not mine. good luck.
[20:22:21] MrPunkin: apeiros: what’s wrong with my attitude?
[20:22:31] MrPunkin: If you can explain to me which part I’m missing I’m more than willing and happy to learn
[20:23:18] MrPunkin: In fact I’d prefer it, I’ve been reading about text encodings since Ruby 1.8.7 and don’t feel any smarter than I did 10 years ago on this particular topic.
[20:31:10] fragamus: has joined #RubyOnRails
[20:34:21] jottr: has joined #RubyOnRails
[20:40:09] IanMalcolm: has joined #RubyOnRails
[20:45:42] MrPunkin: apeiros: here’s actual code… https://gist.github.com/mrpunkin/3268736422c139782df054f712d232bf
[20:49:37] apeiros: oh, so it's actually little endian, not big endian.
[20:55:35] MrPunkin: apeiros: with my end goal being this data becoming hash keys and data, what work do I need to do on the string so that querying the hash by a set of expected keys will work?
[20:56:22] apeiros: the things I already told you. tell ruby the correct encoding via force_encoding, then translate it from there to utf-8 via encode.
[20:59:00] apeiros: (note, it is of course possible to use utf-16le encoded strings as keys, Hash doesn't care)
[20:59:32] MrPunkin: if I use force_encoding(“ASCII-8BIT”) or force_encoding(“UTF-8”) on the initial string or the string just before making a hash from it there is no change to the end result. This is where I clearly have no knowledge of what / when I’m supposed to do
[20:59:57] MrPunkin: I’ve tried all four methods and none result in valid hash key lookups for the “Date” key
[21:00:30] apeiros: "MrPunkin: if I use force_encoding(“ASCII-8BIT”)"
[21:00:35] apeiros: I told you it's utf-16le
[21:01:11] MrPunkin: apeiros: Okay, so in the future how can I determine that myself?
[21:01:20] MrPunkin: Since ruby was saying it had an encoding of ascii?
[21:01:44] MrPunkin: How did you know that?
[21:01:45] apeiros: you're mistaken. ruby wasn't saying that. ruby only reflects what you tell it directly or indirectly.
[21:01:57] apeiros: 22:13 apeiros: encodings can't be automatically detected (guessed at best
[21:02:06] MrPunkin: Okay, I get that. I’m relying on the string variable returned from the core Mail stuff to read the attachment body.
[21:02:27] MrPunkin: So if I receive another file and I can’t trust the software that reads the file how do I know which encoding it is?
[21:02:30] apeiros: and guessing is indeed difficult and takes experience. from your example, the null-bytes in between gave it away.
[21:03:15] apeiros: you chose a bad offset, so it looked like big endian. in your gist, it's visible that it's little endian, though. and the byte order mark ("FF FE") is the strongest indicator for that
[21:03:34] apeiros: but again: guessing is hard and bad. make sure your source tells you the encoding.
[21:03:41] MrPunkin: apeiros: So to expand on what you are saying about guessing… would it be correct to say there isn’t really a way I can accept user-generated files and get proper text output from them consistently because I don’t actually have control of the file data.
[21:04:15] apeiros: correct. if you don't have explicit information, it's a guessing game which is at best unreliable.
[21:05:39] MrPunkin: That’s a huge bummer. I really do appreciate your help with this.
[21:05:56] Turnikov: has joined #RubyOnRails
[21:06:42] apeiros: blame all the suckers who failed to implement (or use) a proper metadata format :-/ it's indeed a bummer and reason for a lot of problems.
[21:06:56] mrbubbles: has joined #RubyOnRails
[21:07:01] mrbubbles: Good evening
[21:07:25] mrbubbles: Does anyone know whether it's possible to use send_file in a rails controller to send an image blob to a JS front end?
[21:08:18] lxsameer: has joined #RubyOnRails
[21:08:47] apeiros: mrbubbles: yes, that's possible.
[21:09:35] mrbubbles: Ah, I was trying to I was use send_file path, type: 'application/pdf', disposition: 'inline' to send a PDF but for some reason the PDFs always come out blank in the front end, so I assumed I was doing something wrong
[21:10:45] Turnikov[m]: has joined #RubyOnRails
[21:11:08] Turnikov[m]: riot.im test (i'm sorry)
[21:12:10] mrbubbles: In the front end I'm using axios to GET the end point (using a Accept: 'application/pdf' header) then constructing a new Blob([response.data]. Does that sound correct?
[21:12:50] apeiros: haven't worked with axios nor Blob, so not sure.
[21:14:46] apeiros: from MDN I'd say the blob part is correct, using GET sounds reasonable.
[21:15:08] apeiros: just test the same URL via browser (or curl, if you need specific headers to be set)
[21:18:42] MrPunkin: apeiros: Okay, since I have a known expected keyset for this hash would it make sense to query the resulting string for one of these header keys and upon each failed attempt try another encoding until the common ones are exhausted? Seems for my specific scenario that could get me working without having any real clue to what the attachments real encoding is.
[21:18:58] mrbubbles: Thanks apeiros. Okay so the URL is working fine, so I guess that the Rails half of things is working great (as usual). Must be the JS end that's screwing up (as usual!)
[21:20:37] apeiros: MrPunkin: sounds sensible.
[21:27:02] duderonomy: has joined #RubyOnRails
[21:27:57] jottr: has joined #RubyOnRails
[21:30:24] ur5us: has joined #RubyOnRails
[21:33:53] tdy: has joined #RubyOnRails
[21:43:11] DTZUZO: has joined #RubyOnRails
[21:52:55] Turnikov: has joined #RubyOnRails
[22:01:17] ShekharReddy: has joined #RubyOnRails
[22:24:36] brandoncc: has joined #RubyOnRails
[22:42:42] fowlduck: has joined #RubyOnRails
[22:43:31] wethu: has joined #RubyOnRails
[22:48:50] FastJack: has joined #RubyOnRails
[22:53:36] DTZUZO: has joined #RubyOnRails
[23:00:52] tdy: has joined #RubyOnRails
[23:03:00] s2013: has joined #RubyOnRails
[23:07:13] cschneid_: has joined #RubyOnRails
[23:09:12] lxsameer: has joined #RubyOnRails
[23:16:47] safetypin: has joined #RubyOnRails
[23:23:29] s2013: has joined #RubyOnRails
[23:24:22] safetypin: has joined #RubyOnRails
[23:36:31] [Butch]: has joined #RubyOnRails
[23:48:54] fragamus: has joined #RubyOnRails
[23:56:57] eckhardt: has joined #RubyOnRails