Shidash

Activity Graph

Page 1 of 2 | Next »

2017-03-28

[03:52:09] Shidash: has left #RubyOnRails: ()

2017-03-27

[13:14:22] Shidash: I've been converting something from a normal class to a Mongoid model (https://github.com/TransparencyToolkit/DocManager/blob/master/app/models/project.rb) and have been having a problem accessing the intial input params from inside the model
[13:15:38] Shidash: The initial object is generated from a JSON config file, so I need to read and parse the file. However, I can't seem to access the project_file input param to do that
[13:17:31] Shidash: I'm calling the model with Project.new(project_file: "path/to/file.json") and it currently gives me an error on line 9 "undefined method 'project_file'". Is there any way to access the project_file variable from inside the model so that I can initialize the project_config variable?
[13:18:24] Shidash: I'm guessing that part of the issue is that the object isn't saved when that line of code is run. But is there really no way to access the parameters passed to the model before the object is saved?
[13:22:14] Shidash: one workaround I've found is to not pass project_file as an input parameter, but instead initialize the project with no parameters and then later call parse_config on the project object and pass the project_file as a param to that method. But this seems a bit messy to have to call both of those methods to initialize a project

2017-03-20

[02:02:33] Shidash: Ping timeout: 260 seconds
[02:03:04] Shidash: has joined #RubyOnRails
[20:42:28] Shidash: Ping timeout: 240 seconds
[20:43:03] Shidash: has joined #RubyOnRails
[22:07:28] Shidash: Ping timeout: 240 seconds
[22:09:15] Shidash: has joined #RubyOnRails

2016-06-28

[10:01:49] Shidash: has left #RubyOnRails: ()
[10:01:50] Shidash: has left #ruby: ()

2016-06-25

[13:51:17] Shidash: Ping timeout: 258 seconds
[13:52:15] Shidash: has joined #RubyOnRails
[13:52:15] Shidash: has joined #ruby

2016-06-15

[23:12:59] Shidash: *.net *.split

2016-05-18

[08:45:43] Shidash: Ping timeout: 250 seconds
[08:54:51] Shidash: has joined #RubyOnRails
[08:54:51] Shidash: has joined #ruby

2016-05-06

[17:56:39] Shidash: Ping timeout: 276 seconds
[17:59:16] Shidash: has joined #RubyOnRails
[17:59:16] Shidash: has joined #ruby

2016-05-05

[00:02:21] Shidash: has joined #ruby
[00:02:22] Shidash: has joined #RubyOnRails

2016-05-04

[23:47:52] Shidash: Ping timeout: 264 seconds

2016-04-18

[11:25:06] Shidash: Ping timeout: 276 seconds
[11:28:29] Shidash: has joined #RubyOnRails
[11:28:29] Shidash: has joined #ruby

2016-04-17

[18:07:04] Shidash: Ping timeout: 276 seconds
[18:08:13] Shidash: has joined #ruby
[18:08:14] Shidash: has joined #RubyOnRails
[19:26:15] Shidash: Ping timeout: 250 seconds
[19:44:22] Shidash: has joined #RubyOnRails
[19:44:22] Shidash: has joined #ruby
[21:41:15] Shidash: *.net *.split
[21:48:33] Shidash: has joined #ruby
[21:48:34] Shidash: has joined #RubyOnRails

2016-04-15

[16:50:01] Shidash: so I'm having a problem that seems a bit stupid- I'm trying to generate html for a link and save it in a string variable so I can use it later. To do this, I'm doing- '<a href="'+url+'">'
[16:50:25] Shidash: hm,wrong channel- think this needs to be in ruby as this would be a solved problem if I was doing it in rails
[16:51:27] Shidash: so I'm having a problem that seems a bit stupid- I'm trying to generate html for a link and save it in a string variable so I can use it later. To do this, I'm doing- '<a href="'+url+'">'
[16:51:56] Shidash: the problem is, when this variable is saved in a JSON, all the double quotes are escaped with a \ before them, so the html does not work
[16:52:43] Shidash: I've tried many variations and can't seem to get a version without escaped double quotes. Printing the variable in irb shows the html correctly, but for some reason the json shows the escaped version
[16:53:16] Shidash: that's literally the code
[16:53:24] Shidash: it's on a different computer, will retype here
[16:54:51] Shidash: yes, I think that's the problem
[16:55:23] Shidash: though when I show the value of the variable in irb, the quotes are also escaped before .to_json, so I'm not sure this is caused by to_json?
[16:57:24] Shidash: jhass: it's definitely a problem. That JSON is later being read by a separate rails app, which can't parse it correctly because of the escaping
[16:58:04] Shidash: yeah, it's split over enough things that I'm not sure how to convey it yet
[16:58:55] Shidash: I was hesitant to post this hear because I still need to clean up one script before I put it on github
[16:59:02] Shidash: but I've been stuck on this for a full day now
[16:59:34] Shidash: jhass: it's not user content. It's links to other pages on the same website
[16:59:42] Shidash: which is read only
[17:01:22] Shidash: jhass: rails app is a general case search tool that works with any dataset. other component is a preprocessing script for a specific dataset.
[17:02:50] Shidash: toretore: because the html is specific to a single field on a single dataset for a single instance of the software
[17:03:12] Shidash: normally it is generated as it is read
[17:09:13] Shidash: https://gist.github.com/anonymous/70293b11a691ecab417eb099f9c9fef0 is a simpler processing script with the same issue. https://github.com/TransparencyToolkit/LookingGlass/blob/master/app/views/docs/_text.html.erb is the view code on the rails side, https://github.com/TransparencyToolkit/LookingGlass/blob/master/app/helpers/doc_format.rb are the processing helpers
[17:09:20] Shidash: the original processing script is pure ruby
[17:10:06] Shidash: if I was generating the links on rails, I'd just use link_to, which avoids this issue.
[17:15:36] Shidash: I think for now I'm just going to print the url and have the rails app handle it like it normally does arrays of links. not ideal, but probably fine and better than wasting more time on this
[17:21:13] Shidash: jhass: I don't think so. It's escaped when I print it in irb, in the JSON file, and when the text from that field is printed in rails
[17:21:28] Shidash: when it's printed in the rails console, that is.
[17:23:26] Shidash: *it's possible it's that, though I've run into that in the past and normally pass things raw (or rather a sanitized version of the html allowing certain tags including a)
[17:24:56] Shidash: the sanitize method I'm using is here- https://github.com/TransparencyToolkit/LookingGlass/blob/master/app/helpers/doc_format.rb, which seems to be what the html_safe method description suggests using instead
[17:25:46] Shidash: raw(text) run in the sanitize method there in the rails console also prints the escaped links
[17:32:46] Shidash: I know. I've spent the past 24 hours failing to debug that
[17:32:49] Shidash: thanks, no thanks, goodbye

2016-04-13

[10:34:04] Shidash: Ping timeout: 268 seconds
[10:38:35] Shidash: has joined #RubyOnRails
[10:38:35] Shidash: has joined #ruby

2016-04-08

[20:27:13] Shidash: has joined #RubyOnRails
[20:27:13] Shidash: has joined #ruby

2016-03-26

[15:01:55] Shidash: has joined #RubyOnRails
[15:01:55] Shidash: has joined #ruby
[15:35:32] Shidash: Remote host closed the connection

2016-03-21

[23:59:25] Shidash: Read error: Connection reset by peer

2016-03-12

[15:29:26] Shidash: Ping timeout: 252 seconds
[15:35:29] Shidash: has joined #RubyOnRails
[15:35:29] Shidash: has joined #ruby

2016-03-09

[12:27:02] Shidash: Ping timeout: 240 seconds
[12:27:11] Shidash: has joined #RubyOnRails
[12:27:11] Shidash: has joined #ruby

2016-03-04

[11:38:25] Shidash: Ping timeout: 244 seconds
[11:41:16] Shidash: has joined #RubyOnRails
[11:41:16] Shidash: has joined #ruby

2016-03-03

[03:27:02] Shidash: has joined #RubyOnRails
[03:27:02] Shidash: has joined #ruby

2016-02-27

[22:30:47] Shidash: has joined #RubyOnRails
[22:30:47] Shidash: has joined #ruby
[23:04:58] Shidash: Ping timeout: 276 seconds

2016-02-22

[20:20:38] Shidash: *.net *.split

2016-02-15

[04:18:48] Shidash: Ping timeout: 272 seconds
[04:20:23] Shidash: has joined #RubyOnRails
[04:20:23] Shidash: has joined #ruby

2016-02-10

[17:59:40] Shidash: Ping timeout: 245 seconds
[18:05:15] Shidash: has joined #RubyOnRails
[18:05:15] Shidash: has joined #ruby

2016-01-25

[14:03:30] Shidash: has joined #ruby
[14:03:31] Shidash: has joined #RubyOnRails

2016-01-20

[13:56:01] Shidash: *.net *.split

2016-01-16

[02:12:45] Shidash: has joined #ruby
[02:12:46] Shidash: has joined #RubyOnRails

2015-12-28

[00:50:26] Shidash: Ping timeout: 240 seconds

2015-12-13

[21:59:25] Shidash: Ping timeout: 250 seconds
[22:05:40] Shidash: has joined #RubyOnRails
[22:05:40] Shidash: has joined #ruby

2015-12-12

[10:11:00] Shidash: Ping timeout: 240 seconds
[10:20:12] Shidash: has joined #RubyOnRails
[10:20:12] Shidash: has joined #ruby
[10:34:24] Shidash: Ping timeout: 264 seconds
[10:41:09] Shidash: has joined #RubyOnRails
[10:41:09] Shidash: has joined #ruby

2015-12-07

[14:48:48] Shidash: Ping timeout: 264 seconds
[14:54:07] Shidash: has joined #RubyOnRails
[14:54:07] Shidash: has joined #ruby

2015-12-06

[13:43:02] Shidash: Ping timeout: 240 seconds
[13:47:58] Shidash: has joined #RubyOnRails
[13:47:58] Shidash: has joined #ruby
[14:05:00] Shidash: Ping timeout: 264 seconds
[14:07:30] Shidash: has joined #RubyOnRails
[14:07:30] Shidash: has joined #ruby

2015-12-02

[15:38:11] Shidash: *.net *.split
[15:41:28] Shidash: has joined #ruby
[15:41:44] Shidash: has joined #RubyOnRails
[15:52:02] Shidash: *.net *.split
[16:47:44] Shidash: has joined #ruby
[16:48:03] Shidash: has joined #RubyOnRails

2015-11-29

[21:38:38] Shidash: Ping timeout: 264 seconds
[21:39:13] Shidash: has joined #RubyOnRails
[21:39:13] Shidash: has joined #ruby
[22:07:43] Shidash: Ping timeout: 264 seconds
[22:09:57] Shidash: has joined #RubyOnRails
[22:09:57] Shidash: has joined #ruby

2015-11-27

[11:11:00] Shidash: Ping timeout: 264 seconds

2015-11-14

[05:51:09] Shidash: Ping timeout: 250 seconds
[05:53:11] Shidash: has joined #ruby
[05:53:12] Shidash: has joined #RubyOnRails
[10:20:31] Shidash: Ping timeout: 252 seconds
[10:21:39] Shidash: has joined #RubyOnRails
[10:21:39] Shidash: has joined #ruby

2015-11-08

[13:35:46] Shidash: has joined #ruby
[13:35:47] Shidash: has joined #RubyOnRails

2015-10-31

[16:40:46] Shidash: Ping timeout: 240 seconds
[16:46:46] Shidash: has joined #RubyOnRails
[16:46:46] Shidash: has joined #ruby
[23:28:53] Shidash: Quit: ZNC - http://znc.in

2015-10-25

[05:23:02] Shidash: I need to set the id to the name of an item. I put self.primary_key = "name" in the model and this seems to work when I check from rails. But when I check postgresql directly, the id is just an integer
[05:23:19] Shidash: is there a way to set the id in postgresql to a string from rails?
[05:36:22] Shidash: arup_r: so just set t.string :id explicitly? or something more?
[05:40:15] Shidash: rhizome: it's for a unique identifier that works across apps
[05:44:21] Shidash: arup_r: doing it at creation is fine- there's no data to be preserved yet
[05:46:03] Shidash: arup_r: already using id: false. Don't see a link though?
[05:46:42] Shidash: arup_r: already doing that
[05:47:16] Shidash: arup_r: the problem is that while it looks like the ID is changed from rails, when I look at the postgres database directly, the ID is just an integer
[05:47:29] Shidash: arup_r: which means that associations don't work
[05:48:29] Shidash: arup_r: in the parent table. the associations are never created because trying to create them with the name-IDs results in errors since it can't find a matching ID in the parent table
[05:49:33] Shidash: arup_r: even though the rails object seems to have the ID in the correct format, for some reason postgres is still saving an integer
[05:51:51] Shidash: arup_r: migrations are https://github.com/TransparencyToolkit/DataLoader/blob/master/db/migrate/20151023215958_create_data_files.rb and https://github.com/TransparencyToolkit/DataLoader/blob/master/db/migrate/20151023220132_create_documents.rb
[05:57:25] Shidash: arup_r: hm... and document_id is an integer there, which is wrong
[05:58:11] Shidash: arup_r: yes
[05:59:05] Shidash: arup_r: yeah, apparently not
[05:59:51] Shidash: arup_r: 4.2.1
[06:09:26] Shidash: arup_r: just got schema to update- think it wasn't updating on migrate for a while. still not working, but now I'm getting a new error- 'unknown attribute document_id'
[06:11:28] Shidash: arup_r: yeah, but in the wrong table heh
[06:15:48] Shidash: arup_r: yup, this seems to work after fixing that

2015-10-23

[10:07:46] Shidash: *.net *.split

2015-10-09

[22:56:00] Shidash: Quit: ZNC - http://znc.in

2015-10-06

[20:43:47] Shidash: *.net *.split
[20:46:18] Shidash: has joined #RubyOnRails
[20:46:21] Shidash: has joined #ruby

2015-09-15

[03:27:28] Shidash: Ping timeout: 246 seconds
[03:30:00] Shidash: has joined #RubyOnRails
[03:30:00] Shidash: has joined #ruby
[03:40:46] Shidash: Ping timeout: 246 seconds
[04:04:01] Shidash: has joined #RubyOnRails
[04:04:01] Shidash: has joined #ruby

2015-09-14

[03:27:55] Shidash: Ping timeout: 246 seconds
[03:28:52] Shidash: has joined #RubyOnRails
[03:28:52] Shidash: has joined #ruby

2015-09-13

[03:24:52] Shidash: Ping timeout: 246 seconds
[03:30:48] Shidash: has joined #RubyOnRails
[03:30:48] Shidash: has joined #ruby
[22:35:01] Shidash: *.net *.split

2015-09-10

[03:25:31] Shidash: Ping timeout: 246 seconds
[03:28:40] Shidash: has joined #RubyOnRails
[03:28:40] Shidash: has joined #ruby

2015-09-09

[00:49:11] Shidash: Ping timeout: 246 seconds
[00:53:25] Shidash: has joined #RubyOnRails
[00:53:25] Shidash: has joined #ruby

2015-09-06

[03:28:44] Shidash: Ping timeout: 246 seconds
[03:31:06] Shidash: has joined #RubyOnRails
[03:31:06] Shidash: has joined #ruby

2015-09-05

[03:25:20] Shidash: Ping timeout: 246 seconds
[03:32:14] Shidash: has joined #ruby
[03:32:15] Shidash: has joined #RubyOnRails

2015-09-04

[03:28:56] Shidash: Ping timeout: 246 seconds
[03:32:55] Shidash: has joined #RubyOnRails
[03:32:55] Shidash: has joined #ruby

2015-09-03

[03:30:13] Shidash: Ping timeout: 244 seconds
[03:32:18] Shidash: has joined #RubyOnRails
[03:32:18] Shidash: has joined #ruby

2015-09-02

[11:02:39] Shidash: Ping timeout: 244 seconds
[11:03:40] Shidash: has joined #RubyOnRails
[11:03:40] Shidash: has joined #ruby
[15:56:39] Shidash: Hi- I'm trying to figure out how to use the same model for multiple datasets to avoid redundancy
[15:56:52] Shidash: I have a rails model Doc and structure of the data it stores is dynamically generated based on a config file. This works well for one dataset- https://github.com/TransparencyToolkit/LookingGlass/blob/master/app/models/doc.rb
[15:57:20] Shidash: But I'd like to reuse this for a few datasets with different config files (and fields). Is there a way to still use just this one Doc class for all datasets?
[15:58:22] Shidash: Sigma00: I thought that had to do with associations between models though?
[15:58:56] Shidash: Sigma00: In this case, there's no association between models. They are just generated with the same code based on different config files
[16:02:04] Shidash: pontiki: don't think the elasticsearch bit matters for this part of the model. I can certainly extract the code I'm using to generate them into a separate function, but ideally I'd like to be able to have n number of datasets and not need to specify a separate model for each in the code in advance
[16:02:38] Shidash: I will if I have to, but that seems a bit messy since all the differences between them are already in the config files
[16:05:05] Shidash: pontiki: yeah- all the config files are specified before startup. So, say there are 3 datasets. Each has their own pre-written config file. Then I want models for each of those to be created at startup (or when they are indexed). Almost like I had specified 3 separate models in the code
[16:10:45] Shidash: pontiki: hm, I guess one slightly better way than manually specifying them would be to write a script that would generate models for each dataspec. It adds a step and isn't super clean, but it can work for n datasets
[16:12:54] Shidash: alternatively, would this be something metaprogramming would be appropriate for? I haven't delved much into it, but it seems like it could work unless there is something with how rails recognizes models that makes it not feasible?
[16:17:06] Shidash: tubbo: they don't update over time. That was just the way I thought of to load them in- there is probably a better way
[16:20:14] Shidash: tubbo: https://github.com/transparencytoolkit/dataspec-icwatch that's an example of some of the config files. There's a lot that needs to be specified about each field, how it is loaded, etc. and it needs to be accessed in many places. I have a separate method loading all of those into variables.
[16:20:56] Shidash: tubbo: and is camel-cased method names not normal/problematic for some reason? did not know that, sorry
[16:23:00] Shidash: pontiki: ah, okay, so mostly just convention. good to know
[16:27:28] Shidash: tubbo: that's what I'm doing
[16:27:54] Shidash: tubbo: there's no normal database behind it. That model is a model for elasticsearch. It isn't storing info from the config file
[16:28:08] Shidash: tubbo: it's just using it to specify the fields. the data is different for each item

2015-08-31

[03:26:11] Shidash: Ping timeout: 246 seconds
[03:31:48] Shidash: has joined #RubyOnRails
[03:31:48] Shidash: has joined #ruby

2015-08-28

[03:27:25] Shidash: Ping timeout: 244 seconds
[03:32:16] Shidash: has joined #RubyOnRails
[03:32:16] Shidash: has joined #ruby
[10:27:06] Shidash: *.net *.split
[10:29:49] Shidash: has joined #RubyOnRails
[10:29:50] Shidash: has joined #ruby

2015-08-24

[13:22:15] Shidash: Ping timeout: 246 seconds
[13:33:14] Shidash: has joined #RubyOnRails
[13:33:14] Shidash: has joined #ruby

2015-08-19

[10:05:43] Shidash: Ping timeout: 246 seconds
[10:08:46] Shidash: has joined #RubyOnRails
[10:08:46] Shidash: has joined #ruby

2015-07-20

[11:22:51] Shidash: Quit: ZNC - http://znc.in
[11:32:22] Shidash: has joined #RubyOnRails
[11:32:22] Shidash: has joined #ruby

2015-07-17

[16:51:55] Shidash: Ping timeout: 246 seconds
[16:54:34] Shidash: has joined #RubyOnRails
[16:54:34] Shidash: has joined #ruby

2015-07-12

[14:57:13] Shidash: has joined #ruby
[14:57:14] Shidash: has joined #RubyOnRails