« Back to channel list

#RubyOnRails - 07 August 2019

« Back 1 day Forward 1 day »
[00:10:36] shtirlic: has joined #RubyOnRails
[01:25:53] ebsen: has joined #RubyOnRails
[01:57:55] uks: has joined #RubyOnRails
[01:57:56] uksio: has joined #RubyOnRails
[02:08:45] ascarter: has joined #RubyOnRails
[02:15:42] Saukk: has joined #RubyOnRails
[02:55:30] mheld: has joined #RubyOnRails
[03:03:11] unixcat: has joined #RubyOnRails
[03:19:01] ebsen: has joined #RubyOnRails
[03:53:52] s2013: has joined #RubyOnRails
[04:09:38] srinidhi: has joined #RubyOnRails
[04:32:32] tdy: has joined #RubyOnRails
[04:41:27] MrCrackPot: has joined #RubyOnRails
[05:23:03] srinidhi: has joined #RubyOnRails
[05:30:38] srinidhi: has joined #RubyOnRails
[05:33:45] srinidhi: has joined #RubyOnRails
[05:35:33] srinidhi: has joined #RubyOnRails
[05:42:14] Aherin: has joined #RubyOnRails
[06:15:50] alxgsv: has joined #RubyOnRails
[06:32:06] alxgsv: has joined #RubyOnRails
[06:46:54] lxsameer: has joined #RubyOnRails
[07:10:19] prestorium: has joined #RubyOnRails
[07:10:31] dionysus69: How do I create an instance of a controller With parameters for rspec test?
[07:11:30] dionysus69: params method returns undefined method `parameters' for nil:NilClass
[07:14:54] za1b1tsu: has joined #RubyOnRails
[07:24:38] tsujp: has joined #RubyOnRails
[07:24:49] tsujp: Is there a point to using ruby on rails with something like react?
[07:46:09] deepredsky: has joined #RubyOnRails
[07:53:43] Ergo: has joined #RubyOnRails
[08:05:50] Duckily: has joined #RubyOnRails
[08:05:52] mikecmpbll: has joined #RubyOnRails
[08:08:11] Sylario: has joined #RubyOnRails
[08:11:24] Intelo: has joined #RubyOnRails
[08:11:30] Intelo: cannot use rvm. can we just use rails internal server to run redmine instead of ngnix or apache
[08:16:55] Intelo: nevermind
[08:24:05] srinidhi: has joined #RubyOnRails
[08:36:40] mikecmpbll: has joined #RubyOnRails
[08:44:13] za1b1tsu: has joined #RubyOnRails
[08:54:45] algun: has joined #RubyOnRails
[08:55:03] algun: Did anyone ever manage to set a table name for a model at runtime?
[09:01:20] Sylario: algun: what are you trying to do?
[09:09:27] Xiti: has joined #RubyOnRails
[09:18:16] algun: sylario: create a temporary table to import a spreadsheet into. This temporary table must be unique to the import... occasion. Hence variable name
[09:19:39] Sylario: algun: you know you can also write to a file if it's a huge spreadsheet
[09:21:08] Sylario: how big is the file?
[09:21:45] algun: I want data in a uniquely-named temporary table for multiple reasons. It's faster to work with (in memory by default, can diff with the [permanent] target table using a performant query), memory management done by the DB, in case of an error the table will be dropped.
[09:22:30] algun: *memory management done by the DB = will write to disk if too big for memory
[09:22:54] algun: So I have reasons, please, a way to set a table name at run time
[09:25:58] Sylario: active record can execute SQL query directly
[09:26:19] algun: i know...
[09:27:04] Sylario: well you can do a 'CREATE TABLE' and you are good to go
[09:27:52] Sylario: SQL command include creating and destroying tables
[09:31:26] algun: The devs I'm supporting aren't SQL savvy I'm afraid. They've managed to create a temporary table through Rails already. What they're stumped with is how to parameterize a model to use the temporary tale they've created.
[09:39:52] Sylario: they can create a non-AR model and create a basic sets of fuction to implement the interactions between the DB and the model
[09:54:00] srinidhi: has joined #RubyOnRails
[10:13:40] algun: sylario, in other words, you think Rails doesn't support it
[10:14:44] Sylario: I do not understand, you can create a table with any name you want with a direct SQL query
[10:15:13] Sylario: you hust do not use AR
[10:15:20] algun: the question isn't about creating the table
[10:16:20] Sylario: it's about giving it the name of the model
[10:16:28] algun: The question is precisely how to parameterize an ActiveRecord so that its table name is set at runtime
[10:17:28] Sylario: Are the attributes of the model dynamic?
[10:17:47] algun: The name of the table is
[10:18:11] Sylario: If the attribute are static, why do you need a dynamic table ?
[10:18:46] Sylario: you just add another attribut to discriminate different spreadsheets
[10:18:50] algun: I explained this when you asked. Each import will be done into its own table
[10:19:02] Sylario: yes but why?
[10:19:29] algun: I explained this as well. In particular, an attribute that differentiate between imports does nothing to remove data in case of failure.
[10:19:40] Sylario: yes yes it does
[10:20:07] Sylario: how does droping or not a table is different from Delete where filename = X
[10:20:23] algun: because a temporary table need not be explicitly dropped
[10:20:27] Sylario: both will or will onot be executed in case of error
[10:20:53] algun: note that in your case, the table can't be temporary because it's used by multiple imports
[10:21:04] Sylario: and what is the problem?
[10:21:20] algun: the data can stick around if something bad happens
[10:21:30] algun: the solution with a temporary table is superior
[10:21:31] Sylario: case multiple table => it fails, the table persist
[10:21:43] algun: because each table is temporary
[10:21:52] Sylario: case discriminating field => it fails the rows persist
[10:21:53] algun: as soon as the connection's severed, the table's dropped
[10:22:46] algun: "Temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction (see ON COMMIT below)."
[10:23:26] Sylario: ok, did not knew about temp tables
[10:23:59] Sylario: I would just create a cron task that delete rows from a job older than one hours or something like that
[10:24:09] Sylario: with a rake task
[10:24:54] algun: I find it strange that Rails' models don't seem to support dynamically-named tables
[10:25:18] Sylario: you probably can create dynamic models
[10:26:00] algun: well I googled, I asked here, so far no luck
[10:27:55] algun: Would you know when ARs are instantiated?
[10:30:30] algun: Is it feasible to just set table_name = 'useredit_'+SecureRandom.uuid and use that name to create a temporary table? Would that be a new name for each request? Or is there a shared pool of ARs across requests, meaning names would not be unique (the UUID would only be calculated once)?
[10:31:11] algun: (user is the "target" table, useredit_*-s are supposed to be the temporary "import" tables)
[10:43:55] lankanmon: has joined #RubyOnRails
[11:48:29] prestorium: has joined #RubyOnRails
[12:00:14] za1b1tsu: has joined #RubyOnRails
[12:27:37] GodFather: has joined #RubyOnRails
[12:28:23] GodFather_: has joined #RubyOnRails
[12:45:59] tsujp: has joined #RubyOnRails
[13:09:22] dionysus69: I am thinking about a functionality that would automatically handle restful routes if they are not present in routes.rb
[13:09:58] dionysus69: something like this Rails.application.routes.append { resources :models }
[13:10:00] dionysus69: Rails.application.reload_routes!
[13:10:42] dionysus69: but before I can run those two lines, routing error gets triggered first
[13:11:35] dionysus69: I am doing this because I am just experimenting around, may not be that useful by the end of the day, but would be great if just declaring controller/action would deduce the route in case of restful actions at least*
[13:30:20] uks: has joined #RubyOnRails
[13:30:21] uksio: has joined #RubyOnRails
[13:39:29] tsujp: has joined #RubyOnRails
[13:56:28] tsujp: has joined #RubyOnRails
[14:09:43] Frem: has joined #RubyOnRails
[14:14:29] deepredsky: has joined #RubyOnRails
[14:25:47] deepredsky: has joined #RubyOnRails
[14:27:18] s2013: has joined #RubyOnRails
[14:27:31] srinidhi: has joined #RubyOnRails
[14:49:20] srinidhi: has joined #RubyOnRails
[15:14:24] GodFather_: has joined #RubyOnRails
[15:14:26] GodFather: has joined #RubyOnRails
[15:21:39] fyber: has joined #RubyOnRails
[15:25:04] byteflam1: has joined #RubyOnRails
[15:25:21] ascarter: has joined #RubyOnRails
[15:46:00] za1b1tsu: has joined #RubyOnRails
[15:57:58] ellcs: has joined #RubyOnRails
[15:58:57] ellcs: has joined #RubyOnRails
[16:07:30] duderonomy: has joined #RubyOnRails
[16:13:50] KeyJoo: has joined #RubyOnRails
[16:25:00] tdy: has joined #RubyOnRails
[16:26:09] duderonomy: has joined #RubyOnRails
[16:34:54] srinidhi: has joined #RubyOnRails
[16:37:44] srinidhi: has joined #RubyOnRails
[16:54:28] duderonomy: has joined #RubyOnRails
[16:55:04] _aeris: has joined #RubyOnRails
[16:55:07] srinidhi: has joined #RubyOnRails
[16:55:57] FastJack: has joined #RubyOnRails
[17:02:39] srinidhi: has joined #RubyOnRails
[17:04:09] byteflam1: has joined #RubyOnRails
[17:10:15] dviola: has joined #RubyOnRails
[17:12:36] deepredsky: has joined #RubyOnRails
[17:15:57] dviola: I'm trying to get rid of this each loop: https://github.com/diegoviola/fromthepage/blob/1175-remove-show-to-method/app/controllers/dashboard_controller.rb#L55-L59
[17:16:26] dviola: the problem is it calls all these model methods: like_owner? and collaborator? -- it expects a loop of some sort
[17:16:40] dviola: but looping on 1k records is slow
[17:18:08] byteflam1: has joined #RubyOnRails
[17:22:42] lankanmon: has joined #RubyOnRails
[17:23:35] havenwood: dviola: use #map instead of shoveling onto an Array with #each
[17:24:14] havenwood: dviola: it seems line 56 could simply be done in the query, which would presumably reduce the collection size before iteration
[17:25:12] havenwood: dviola: i usually recommend chaining off of #find_each, if you really want to iterate over large collections so it'll be in proper batches
[17:25:34] havenwood: dviola: find_each.map do
[17:25:58] dviola: havenwood: thanks, I'll try those suggestions
[17:26:17] havenwood: dviola: though I guess you're using a #filter_map, which Ruby doesn't add until version 2.7 this Christmas
[17:26:36] havenwood: Err, this is just a #select. Nevermind.
[17:26:47] havenwood: dviola: find_each.select do
[17:27:20] havenwood: dviola: It's hard to say how to optimize #like_owner? and #collaborator? without knowing what those do.
[17:28:27] dviola: havenwood: https://github.com/diegoviola/fromthepage/blob/master/app/models/user.rb#L102-L121 -- btw, I don't expect you to tell me how to rewrite this one
[17:29:25] dviola: collaborator? is here: https://github.com/diegoviola/fromthepage/blob/master/app/models/user.rb#L102-L121
[17:30:21] dviola: https://github.com/diegoviola/fromthepage/blob/master/app/models/user.rb#L98-L100
[17:30:53] havenwood: dviola: obj.instance_of?(Collection)
[17:31:25] havenwood: dviola: ^ that's a bit more efficient (presuming, haven't benchmarked) way to check: Collection == obj.class
[17:32:12] dviola: havenwood: cool, thanks a lot :)
[17:32:39] havenwood: dviola: yeah, I can't see how to rewrite this for efficiency on first glance
[17:32:46] havenwood: dviola: no prob!
[17:33:21] havenwood: dviola: How about a scope on Collection and DocumentSet by owner?
[17:34:42] dviola: I thought about that as well, good idea
[17:56:57] byteflam1: has joined #RubyOnRails
[17:59:20] deepredsky: has joined #RubyOnRails
[18:06:00] s00pcan: has joined #RubyOnRails
[18:10:39] hive-mind: has joined #RubyOnRails
[18:13:35] xco: has joined #RubyOnRails
[18:14:29] xco: hi is there a better way to get current time and date nicely formatted like “August 07, 2019 20:11” without using strftime?
[18:15:26] xco: Got it Time.current.to_s(:long)
[18:33:32] GodFather: has joined #RubyOnRails
[18:33:49] byteflam1: has joined #RubyOnRails
[18:34:04] GodFather_: has joined #RubyOnRails
[18:47:19] byteflam1: has joined #RubyOnRails
[19:00:52] Quintasan: has joined #RubyOnRails
[19:03:33] byteflam1: has joined #RubyOnRails
[19:16:29] deepredsky: has joined #RubyOnRails
[19:18:01] sameerynho: has joined #RubyOnRails
[19:20:48] ascarter: has joined #RubyOnRails
[19:21:38] Aherin: has joined #RubyOnRails
[19:40:54] Aherin: has joined #RubyOnRails
[19:48:36] jefffrails35: has joined #RubyOnRails
[19:58:07] eddof13: has joined #RubyOnRails
[20:00:01] jefffrails35: has joined #RubyOnRails
[20:04:16] s2013: has joined #RubyOnRails
[20:17:50] defsdoor: has joined #RubyOnRails
[20:20:04] matt76: has joined #RubyOnRails
[20:23:24] Linell: xco: TIL, that's neat!
[20:24:35] xco: Linell: ;)
[20:33:43] byteflam1: has joined #RubyOnRails
[20:34:02] ellcs: has joined #RubyOnRails
[20:43:09] eddof13: has joined #RubyOnRails
[20:55:59] s2013: has joined #RubyOnRails
[21:00:43] admin123: has joined #RubyOnRails
[21:08:34] GoldenBear: has joined #RubyOnRails
[21:48:17] GodFather_: has joined #RubyOnRails
[21:48:23] GodFather: has joined #RubyOnRails
[21:52:24] ascarter: has joined #RubyOnRails
[22:03:23] swillits: has joined #RubyOnRails
[22:04:26] swillits: has left #RubyOnRails: ("Textual IRC Client: www.textualapp.com")
[22:08:52] ascarter: has joined #RubyOnRails
[22:15:07] ^amra: has joined #RubyOnRails
[22:19:46] eddof13: has joined #RubyOnRails
[22:33:45] fragamus: has joined #RubyOnRails
[23:01:00] morenoh149: has joined #RubyOnRails
[23:31:06] gambl0re: has joined #RubyOnRails
[23:40:32] morenoh149: has joined #RubyOnRails
[23:41:22] byteflam1: has joined #RubyOnRails
[23:44:33] eddof13: has joined #RubyOnRails