Page 1 of 1
[00:55:49] cxl: Hey so I have a hard time deciding whether a method should go on the model on in the controller. Is there a rule of thumb I could follow when in doubt?
[02:02:19] cxl: Radar: in that case, it was this method: https://github.com/mhartl/sample_app_3rd_edition/blob/master/app/models/user.rb#L81-L86 and I wasn't sure whether it should go in the controller or the model.
[02:03:38] cxl: so it uses the user id from the request in a way, since users are identified with a cookie
[20:11:30] cxl: Is this kind of side effect good practice in Ruby/Rails? I'm surprised to see it in the rails tutorial: https://bitbucket.org/railstutorial/sample_app_4th_ed/src/6f522278a8e2f0c65738bb10ac09a265a727be42/app/helpers/sessions_helper.rb#lines-22
[21:34:06] cxl: Inside: It's still in the latest version: https://www.railstutorial.org/book/advanced_login#code-persistent_current_user
[00:58:46] cxl: Hi, I can't wrap my head around this one: is there a difference between using self or the class name: https://dpaste.de/UzcZ ?
[01:18:09] cxl: wait, there is a difference, but I can't tell what it is. In this code: https://dpaste.de/poKn, if I replace all the User. with self., and then do User.first.remember in the rails console, it can't find the new_token method. But if I use User. as it is in the dpaste, then it works. I don't understand why that is.
[01:53:57] cxl: I haven't done Ruby in a while, and I can't understand why Foo.new_token works but not self.new_token in this snippet: https://dpaste.de/33c9
[15:15:10] cxl: Vashy: looks like your rvm doesn't work well (system is using 2.3.0). Try running `rvm` and scroll back up to see if it complains about not being in path or something of the sort. If it does, you need to fix your rvm install, #rvm could be of help.
[15:52:44] cxl: Ugh, self and classes are confusing me even more now that I'm digging into it. Why is method1 undefined on L11? https://repl.it/repls/DualFrostyCopyleft
[15:53:24] cxl: Wouldn't self in that context be an instance of Foo, and it having not instance method called method1 then wouldn't it climb up to the class to look for it there?
[15:54:42] cxl: havenwood: what am I missing? If I run that code it says undefined method method1 in the repl
[15:56:53] cxl: I thought ruby would look for a given method in the instance first, and then in the class if it can't find it.
[16:00:09] cxl: so my issue is only because I thought that the pattern was look for method on instance, and then up the class and superclasses if not found, but instead it's look it up on the instance and fail if it's not there?
[16:01:34] cxl: and to declare instance methods from the class, I'd have to do it in the constructor, as self.mymethod?