cxl

Activity Graph

Page 1 of 1

2018-11-15

[06:40:43] cxl: Quit: bye

2018-11-09

[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?
[00:56:07] cxl: s/on in/or in
[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

2018-11-06

[06:32:33] cxl: Ping timeout: 252 seconds
[15:16:50] cxl: has joined #ruby
[15:16:50] cxl: has joined #RubyOnRails

2018-10-31

[14:13:52] cxl: Ping timeout: 264 seconds
[14:18:27] cxl: has joined #ruby
[14:18:27] cxl: has joined #RubyOnRails

2018-10-29

[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
[20:11:51] cxl: s/good/accepted
[21:34:06] cxl: Inside: It's still in the latest version: https://www.railstutorial.org/book/advanced_login#code-persistent_current_user

2018-10-24

[06:37:35] cxl: Quit: bye
[13:42:35] cxl: has joined #ruby
[13:42:35] cxl: has joined #RubyOnRails

2018-10-21

[00:58:12] cxl: has joined #ruby
[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:00:45] cxl: so they are equivalent, but the first is prefered?
[01:01:07] cxl: Or is there ever a good reason to use the class name instead of self?
[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:30:51] cxl: I still don't get why User.first can't resolve self.new_token to User.new_token
[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:55:03] cxl: oh my bad, it's probably tripping on L25 rather
[15:56:02] cxl: but why then? on that line, wouldn't foo.method1 run the class method?
[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.
[15:57:06] cxl: and so on until it ran out of superclasses
[15:58:15] cxl: so on L11, what is `self` then? The instance?
[15:59:24] cxl: ok, but I can't call any of these def Foo/self methods from the instance?
[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?
[16:01:40] cxl: ACTION looks that book up
[16:09:44] cxl: thank you