« Back to channel list

#RubyOnRails - 15 July 2019

« Back 1 day Forward 1 day »
[00:11:23] skryking: has joined #RubyOnRails
[00:21:46] Exuma: has joined #RubyOnRails
[00:36:12] ariedler: has joined #RubyOnRails
[00:48:30] Dr_MDMA_MD: has joined #RubyOnRails
[01:04:55] tdy: has joined #RubyOnRails
[01:11:34] ElFerna: has joined #RubyOnRails
[01:12:27] fernando: has joined #RubyOnRails
[01:33:07] BloopMonster: has joined #RubyOnRails
[01:58:36] kristofers: has joined #RubyOnRails
[02:02:12] dionysus69: has joined #RubyOnRails
[02:28:21] TvL2386: has joined #RubyOnRails
[02:33:25] TvL2386: has joined #RubyOnRails
[03:07:45] Saukk: has joined #RubyOnRails
[04:01:04] dtzuzu: has joined #RubyOnRails
[04:05:02] DTZUZO: has joined #RubyOnRails
[04:12:45] Norrin: I feel like my team is trying to do something silly. They want to make a string column with UUIDs in it instead of using the default id primary key
[04:13:26] dgs: imo, a primary key should never be meaningful
[04:13:34] Norrin: they think it makes sense in case tables ever move, the UUIDs will be the same but the default id column would not?
[04:14:07] Norrin: what does that mean? dgs
[04:14:21] Norrin: a UUID is meaningful?
[04:14:27] dgs: i have a legacy app where the user names are the primary key
[04:14:34] dgs: and referenced everywhere
[04:14:39] dgs: and it's a pita
[04:15:04] Norrin: I'm sure. they're not unique i would assume
[04:15:12] dgs: you can't change them ... and perhaps what you want now, but who's to say that will hold true forever
[04:15:19] dgs: *thats what you want
[04:15:59] dgs: meaningful - as in it has some meaning outside of it's PK uniqueness
[04:16:34] Norrin: ok. I'd say that UUIDs fit that description. meaningless other than them being unique
[04:16:44] dgs: not to mention it's breaks convention / is non standard, which can be a pain with ORM's and needs to be managed
[04:17:41] dgs: plus more overhead compared to just picking up the next value of a sequence
[04:18:02] dgs: not to say there's never a reason to do so
[04:18:12] Norrin: I agree about the performance concern
[04:18:30] Norrin: for some reason this company has a culture of not caring about performance
[04:18:38] dgs: but if i was starting something from scratch, there would need to be a fairly compelling reason not to go with the standard PK + sequence
[04:18:39] Norrin: so their fear is that default id's might change if some records were deleted or the table moved & altered in some way. Does that sound realistic?
[04:19:00] dgs: the id might change? or the uuid might change?
[04:19:19] dgs: a PK should pretty much never change - even if stuff gets deleted
[04:19:25] dgs: gappiness is fine
[04:19:33] Norrin: default AR ID
[04:19:50] dgs: that should never change
[04:19:57] dgs: that's the whole ponit
[04:19:57] Norrin: ok, thanks
[04:20:08] Norrin: don't know where the teach lead is getting this bs...
[04:20:22] Norrin: i just rolled on. imma look this guy up
[04:20:38] Norrin: s/teach/tech/
[04:22:53] za1b1tsu: has joined #RubyOnRails
[04:26:59] ascarter: has joined #RubyOnRails
[04:31:03] za1b1tsu: has joined #RubyOnRails
[04:32:47] tdy: has joined #RubyOnRails
[04:38:24] fragamus: has joined #RubyOnRails
[04:45:35] lankanmon: has joined #RubyOnRails
[05:14:51] srinidhi: has joined #RubyOnRails
[05:18:57] s2013: has joined #RubyOnRails
[05:19:37] conta: has joined #RubyOnRails
[05:26:07] conta: has joined #RubyOnRails
[05:28:03] za1b1tsu: has joined #RubyOnRails
[06:00:37] conta: has joined #RubyOnRails
[06:03:14] lankanmon: has joined #RubyOnRails
[06:15:27] schneider: has joined #RubyOnRails
[06:22:17] tdy: has joined #RubyOnRails
[06:23:27] tdy: has joined #RubyOnRails
[06:47:52] tdy: has joined #RubyOnRails
[06:54:18] pro777: has joined #RubyOnRails
[06:58:08] tdy: has joined #RubyOnRails
[06:59:45] Dr_MDMA_MD: has joined #RubyOnRails
[07:02:11] DTZUZO: has joined #RubyOnRails
[07:16:17] m17: has joined #RubyOnRails
[07:16:17] jtperreault: has joined #RubyOnRails
[07:16:17] Fenhl: has joined #RubyOnRails
[07:16:17] voker57: has joined #RubyOnRails
[07:16:17] keden: has joined #RubyOnRails
[07:16:17] G: has joined #RubyOnRails
[07:16:17] phon: has joined #RubyOnRails
[07:16:18] newton: has joined #RubyOnRails
[07:16:18] Vircung: has joined #RubyOnRails
[07:16:18] leeky: has joined #RubyOnRails
[07:16:18] KindOne: has joined #RubyOnRails
[07:16:18] Net: has joined #RubyOnRails
[07:16:44] MrCrackPotBuilde: has joined #RubyOnRails
[07:16:44] FooBarWidget: has joined #RubyOnRails
[07:16:44] lupine: has joined #RubyOnRails
[07:16:44] shansen: has joined #RubyOnRails
[07:16:44] arathald: has joined #RubyOnRails
[07:19:30] conta: has joined #RubyOnRails
[07:26:27] bga57: has joined #RubyOnRails
[07:27:02] lxsameer: has joined #RubyOnRails
[07:31:00] conta: has joined #RubyOnRails
[08:03:55] MrCrackPotBuilde: has joined #RubyOnRails
[08:09:01] Bounga: has joined #RubyOnRails
[08:12:06] schne1der: has joined #RubyOnRails
[08:14:23] conta: has joined #RubyOnRails
[08:35:40] arathald: has joined #RubyOnRails
[08:35:49] shansen: has joined #RubyOnRails
[08:35:52] FooBarWidget: has joined #RubyOnRails
[08:36:20] phon: has joined #RubyOnRails
[08:36:21] G: has joined #RubyOnRails
[08:36:26] voker57: has joined #RubyOnRails
[08:36:26] Vircung: has joined #RubyOnRails
[08:36:47] newton: has joined #RubyOnRails
[08:36:47] leeky: has joined #RubyOnRails
[08:36:51] Fenhl: has joined #RubyOnRails
[08:36:59] keden: has joined #RubyOnRails
[08:37:07] uplime^: has joined #RubyOnRails
[08:37:17] jtperreault: has joined #RubyOnRails
[08:37:17] MrCrackPotBuilde: has joined #RubyOnRails
[08:37:18] lupine: has joined #RubyOnRails
[08:46:45] dionysus69: has joined #RubyOnRails
[08:52:00] pokalyis: has joined #RubyOnRails
[09:15:17] conta: has joined #RubyOnRails
[09:25:52] za1b1tsu: has joined #RubyOnRails
[09:30:24] Norrin: this guide is saying that db constraints on uniqueness cannot be done on multi column indexes. https://guides.rubyonrails.org/active_record_validations.html#uniqueness
[09:30:38] Norrin: but SO has posts that show how to do it. can the guide be updated?
[09:30:48] Norrin: https://stackoverflow.com/questions/1449459/how-do-i-make-a-column-unique-and-index-it-in-a-ruby-on-rails-migration/1449466#1449466
[09:38:53] tdy: has joined #RubyOnRails
[09:57:40] DTZUZO: has joined #RubyOnRails
[10:14:03] conta: has joined #RubyOnRails
[10:20:18] kapilp: has joined #RubyOnRails
[10:38:09] ephemer0l: has joined #RubyOnRails
[11:15:31] tf2ftw: has joined #RubyOnRails
[11:40:34] lankanmon: has joined #RubyOnRails
[11:49:55] lato_1: has joined #RubyOnRails
[11:52:08] gregf_: has joined #RubyOnRails
[11:58:38] Dbugger: has joined #RubyOnRails
[12:00:13] jefffrails35: has joined #RubyOnRails
[12:04:49] srinidhi: has joined #RubyOnRails
[12:12:03] DTZUZO: has joined #RubyOnRails
[12:19:40] conta1: has joined #RubyOnRails
[12:23:20] Sylario: has joined #RubyOnRails
[12:24:17] Tempesta: has joined #RubyOnRails
[12:33:28] ZAJDAN: is possible via Devise do autorisation on selected update actions?
[12:35:12] Sylario: ZAJDAN: Devise only give you authentication. For authorization, you need to do it on your own
[12:36:43] Sylario: cancancan is a popular solution
[12:38:13] ZAJDAN: thnx for the tip ...will look on it
[12:38:22] Sylario: ZAJDAN: I use pundit because it allow to modify the scope based on authorization, but it's heavier than cancancan to implement
[12:43:23] tdy: has joined #RubyOnRails
[12:47:31] Norrin: on https://guides.rubyonrails.org/association_basics.html there is a phrase that reads: "Rails will not create foreign key columns for you. You need to explicitly define them as part of your migrations."
[12:48:23] Norrin: It's rather confusing. It's kind of not true. if you list a reference in a migration it does create the column for you....
[12:50:13] tdy: has joined #RubyOnRails
[12:56:57] ZAJDAN: sylario: and 'cancancan' uses Devise user accounts?
[12:57:23] ZAJDAN: where is the connection between Devise and Cancancan ...?
[12:59:14] Sylario: ZADJAN : tehre is none, cancancan do not need devise
[13:00:05] ZAJDAN: but on some accouns it must operate
[13:00:33] ZAJDAN: how it will identify who is who
[13:00:43] Sylario: devise allow you to know that visitor V is tied to user account N. cancancan will check that user N can do action Foo or not.
[13:01:20] Sylario: https://github.com/CanCanCommunity/cancancan#controller-helpers
[13:01:30] Sylario: CanCanCan expects a current_user method to exist in the controller.
[13:02:20] Sylario: In fact cancancan do works with Devise
[13:02:30] Sylario: out of the box
[13:15:52] Norrin: how can https://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-add_reference be updated so that it mentions that the hash passed to foreign_key is forwarded to add_foreign_key, and therefore that the hash documentation is listed under add_foreign_key ?
[13:37:26] ZAJDAN: sylario: thank You
[13:43:57] Norrin: how do you add a database contraint on uniqueness that is scoped?
[13:49:23] tf2ftw: has joined #RubyOnRails
[13:52:50] tdy: has joined #RubyOnRails
[13:57:29] tdy: has joined #RubyOnRails
[14:01:15] tdy: has joined #RubyOnRails
[14:14:45] fragamus: has joined #RubyOnRails
[14:22:32] schne1der: has joined #RubyOnRails
[14:30:48] tf2ftw: has joined #RubyOnRails
[14:38:47] ElFerna: has joined #RubyOnRails
[14:41:17] s2013: has joined #RubyOnRails
[14:48:09] emachnic: has joined #RubyOnRails
[14:56:37] agent_white: has joined #RubyOnRails
[15:22:27] unreal: has joined #RubyOnRails
[15:23:30] bretzel: has joined #RubyOnRails
[15:28:29] snk: has joined #RubyOnRails
[15:29:31] bretzel: Hi, what is "mysql2" - because gem install mysql fails. So not with mysql2
[15:34:11] unreal: has joined #RubyOnRails
[15:34:36] agent_white: has joined #RubyOnRails
[15:42:09] tdy: has joined #RubyOnRails
[15:45:09] agent_white: has joined #RubyOnRails
[15:51:01] snowy: has joined #RubyOnRails
[15:55:55] havenwood: bretzel: they're two different gems for MySQL. use mysql2.
[16:00:36] s2013: has joined #RubyOnRails
[16:07:47] uks: has joined #RubyOnRails
[16:12:00] orbyt_: has joined #RubyOnRails
[16:13:14] fragamus: has joined #RubyOnRails
[16:34:34] orbyt_: has joined #RubyOnRails
[16:47:39] tdy: has joined #RubyOnRails
[17:02:15] lankanmon: has joined #RubyOnRails
[17:03:57] fragamus: has joined #RubyOnRails
[17:06:27] jamaio: has joined #RubyOnRails
[17:06:33] bretzel: havenwood: (sorry I was AFK) . Okay thanks alot. :)
[17:07:27] jamaio: Hello. Is it a good idea to isolate all logic that might be in a controller into a service object?
[17:08:27] jamaio: Like, if I have code that calls the model in the controller is that something I should avoid?
[17:09:04] hive-mind: has joined #RubyOnRails
[17:10:25] sameerynho: has joined #RubyOnRails
[17:16:11] havenwood: jamaio: Have an example of the logic you're talking about? Is the app already using service objects?
[17:18:11] havenwood: jamaio: I think _all logic_ is too broad of a generality, since controller logic to fetch or save from the model is appropriate for the controller.
[17:18:24] jamaio: havenwood: not using any service objects yet. mostly just crud on the different resource types in my app with a few third-party api calls
[17:18:25] havenwood: jamaio: "A controller can thus be thought of as a middleman between models and views."
[17:19:31] havenwood: jamaio: It's fine if the logic in the controller isn't about getting the data it needs from a model to serve up in a view.
[17:19:38] havenwood: That's what controllers are for!
[17:20:22] jamaio: sorry, i think i'm confused by "isn't about". you're saying it is or is not okay for that logic to be in the controller?
[17:22:10] havenwood: jamaio: Be suspicious of non-controller logic in the controller! If there's a recipe for french toast in your controller, or internal logic about using an API, or that type of thing, it probably doesn't belong there. If there's logic about which model info needs to be passed to the view, that's what controllers are for.
[17:25:00] havenwood: jamaio: Check out, for example, the types of things in controllers/ versus services/ here: https://github.com/discourse/discourse/tree/master/app
[17:25:36] jamaio: thanks, that really clears up the thinking for me. i like the way you put it. so if i need to kick off a process in the request, but it's response is not required for the view, maybe use a service or a job- otherwise don't be afraid to grab data from the model and pass it to the view right in the controller. sound good?
[17:25:52] havenwood: Also, TIMTOWTDI. I'd suggest sticking with Rails convention as close as you can until you have a good reason to go off the Rails.
[17:26:12] havenwood: jamaio: 👍🏽
[17:27:54] jamaio: perfect! it seems like some of the more philosophical articles on service objects suggest wrapping any business logic inside them, so you end up with tiny controllers. not sure how i feel about being that strict. the argument of code being able to test is interesting
[17:29:48] jamaio: i guess really that's the best argument i've seen, being easier to test. but is it really that hard to test controllers directly?
[17:36:53] srinidhi: has joined #RubyOnRails
[17:38:58] srinidhi: has joined #RubyOnRails
[17:39:20] GodFather: has joined #RubyOnRails
[17:41:54] sameerynho: has joined #RubyOnRails
[17:44:24] havenwood: jamaio: If the view doesn't end up with the right data from the model, the controllers aren't working. Rails has actually backed a bit away from tons of controller tests. There were some interesting articles on why.
[17:44:32] srinidhi: has joined #RubyOnRails
[17:44:40] havenwood: jamaio: They're not particularly hard to unit test.
[17:45:55] jamaio: havenwood: oh so you're saying that typically one doesn't actually write tests for the controllers?
[17:47:53] havenwood: jamaio: I said that badly. I write functional tests for controllers. There were some helper functions for going deeper with controller tests that were removed, because they were seen as testing internals and not useful. You can use them as a gem now. https://guides.rubyonrails.org/testing.html#functional-tests-for-your-controllers
[17:48:28] havenwood: jamaio: I just meant #assigns, #assert_template, etc: https://github.com/rails/rails-controller-testing
[17:48:59] havenwood: jamaio: https://blog.bigbinary.com/2016/04/19/changes-to-test-controllers-in-rails-5.html#deprecation-of-assigns-and-assert_template-in-controller-tests
[17:49:37] jamaio: ah i see. so you want to write integration tests, not unit tests for controllers nowadays
[17:50:11] havenwood: "The idea behind the removal of these methods is that instance variables and which template is rendered in a controller action are internals of a controller, and controller tests should not care about them."
[18:03:30] psilly0: has joined #RubyOnRails
[18:27:24] srinidhi: has joined #RubyOnRails
[18:33:51] conta1: has joined #RubyOnRails
[18:44:15] GodFather: has joined #RubyOnRails
[19:37:05] conta1: has joined #RubyOnRails
[20:53:43] defsdoor: has joined #RubyOnRails
[21:26:02] ellcs: has joined #RubyOnRails
[21:26:48] ellcs: has joined #RubyOnRails
[21:50:00] s2013: has joined #RubyOnRails
[21:54:41] GodFather: has joined #RubyOnRails
[21:55:12] Fernando-Basso: has joined #RubyOnRails
[22:05:49] tf2ftw: has joined #RubyOnRails
[22:32:43] Dr_MDMA_MD: has joined #RubyOnRails
[22:43:57] duderonomy: has joined #RubyOnRails
[22:47:27] tdy: has joined #RubyOnRails
[23:30:29] orbyt_: has joined #RubyOnRails
[23:30:44] agent_white: has joined #RubyOnRails