Activity Graph

Page 1 of 3 | Next »


[10:51:54] garyserj: I know the alert line works though because when sending a message from server to client, I trigger it. It's just that the last line in the coffeescript, which is meant to send from client to server, is not triggering that received method, / is not causing an alert
[10:51:54] garyserj: that last line doesn't seem to cause an alert, so it doesn't seem to trigger the received method
[10:51:54] garyserj: but that last line isn't working
[10:51:54] garyserj: I am trying to use action cable. I got the server to send to the client. But I also want the client to send to the server. I tried this in my coffeescript file
[10:52:04] garyserj: sorry not sure why it put that on so many new lines but anyhow.


[05:33:49] garyserj: aaa={a::abc} so i'm a but confused over what that syntax id: :email means in terms of ruby?
[05:33:49] garyserj: this is a ruby question rather than a rails question, but i see this syntax in rails form.text_field :email, id: :email, class: :email and it puzzles me 'cos id: :email looks to me like a key value pair (is it?), but if I try in irb aaa={:a=>:4} that doesn't work. It looks like the value(of the key value pair) can't be a symbol, only the key is. You can say aaa={a:"abc"} but not
[05:44:20] garyserj: has joined #RubyOnRails
[07:29:07] garyserj: havenwood: thanks
[07:56:26] garyserj: I have a method ddd that takes two parameters. And I try to call it ddd {:g=>"aaa"},{:r=>"www"} but why does that give a syntax error regarding => and }?
[08:10:17] garyserj: havenwood: ok, thanks
[08:19:38] garyserj: ddd {:g=>"aaa"},({:r=>"www"}) <-- that also gives an error
[08:58:40] garyserj: thanks. I can see now how if the last argument contains {..} then you need parens around the arguments list, but why does this give a syntax error ddd {:g=>"aaa"},r:"www" My last argument has no {...} so why is there an issue?
[09:00:59] garyserj: ziyadb: you mean the difference?
[09:06:05] garyserj: i see a form for creating an new user, and a search form.. the new user one uses a post , the search form uses a get.. so is your question why the search form uses GET? Maybe you can share the code that produced the search form?
[09:29:46] garyserj: ryouba: i don't know, but any idea with my question, it looks easier?
[09:42:28] garyserj: ah ok, thanks.. so any { } for a hash, in any of a method's arguments, requires parens around the list of arguments?
[09:51:01] garyserj: phaul: suppose i do want to pass a block then, followed by a value. ddd {a=1},2 gives an error
[09:55:04] garyserj: so since a block can only be in the last position, why should a {} for a hash in an argument prior to the last position, cause a need for parens around all arguments?
[09:56:45] garyserj: similarly, if {block},r makes no sense, then why isn't it seen as {hash},r Why should it attempt to view an argument prior to the last argument, as a block. There is no ambiguity with an argument prior to the last argument
[09:58:05] garyserj: sounds primitive to state there's a syntax error without reading as far as the end of the line
[10:00:36] garyserj: well, if other languages do that, it doesn't seem so absurd 'cos they don't try to be clever like ruby does with skipping parens (skipping parens on a basis of ambiguity, when the interpreter isn't really spotting ambiguity properly 'cos it doesn't read to the end of a line)
[10:02:09] garyserj: ryouba: yeah well sometimes I have to read other code, like the scaffolding rails generates.
[10:37:01] garyserj: So how is it deciding whether to show a blank form or a form with a user's data? rail generate scaffold uses form_with and a file _form.html.erb which uses the same generic form for new user or editing a user, and it somehow knows what to fill the form with, but I can't see how
[10:37:01] garyserj: I can see how form_for knows whether to show a blank form, or the form with user's data, 'cos it is based on variable e.g. form_for @user and if or if e.g. user=User.all[0] Then it responds accordingly. But I understand that now form_for is replaced with form_with which has the header of form_with(model: user, local: true) do |form| So, it's not looking at a variable @user
[10:42:01] garyserj: I can't see a value ever being assigned to a variable user.. i'm looking in the user_controller.rb and in _form.html.erb
[10:44:30] garyserj: if the variable were local to the form, then how would the form know?
[10:44:54] garyserj: (I think it's the same form used for whether the user clicks edit, or whether the user clicks to create a new user)
[10:45:17] garyserj: oh I see I think it's passing a variable in
[10:50:37] garyserj: thanks.. also, when I look at the html of the form with the update button, it says method="post", whereas rails routes indicates that the acion should be 'put'. So why does it have method="post"?
[11:01:43] garyserj: wow, thanks
[11:02:08] garyserj: yeah i see now, ta


[16:50:09] garyserj: *.net *.split


[23:17:28] garyserj: has joined #ruby


[02:42:28] garyserj: has joined #ruby
[02:55:18] garyserj: Ping timeout: 246 seconds


[02:39:58] garyserj: Ping timeout: 246 seconds


[11:20:31] garyserj: has joined #ruby


[11:28:41] garyserj: has joined #ruby
[11:31:06] garyserj: Client Quit


[12:06:11] garyserj: Disconnected by services
[12:07:06] garyserj: has joined #RubyOnRails
[12:07:34] garyserj: where is rails located in mac osx? (i'm having trouble installing it so perhaps somebody can do which rails and let me know the path? thanks)
[13:18:28] garyserj: Ping timeout: 272 seconds


[14:01:38] garyserj: has joined #ruby


[23:16:53] garyserj: has joined #ruby
[23:22:58] garyserj: has left #ruby: ()


[11:31:25] garyserj: has joined #ruby
[12:06:06] garyserj: Quit: garyserj


[03:56:57] garyserj: has joined #ruby
[04:09:18] garyserj: Quit: garyserj


[03:10:08] garyserj: Quit: garyserj


[05:22:41] garyserj: Quit: garyserj
[20:22:11] garyserj: has joined #ruby
[21:02:00] garyserj: Quit: garyserj
[21:46:26] garyserj: has joined #ruby


[20:41:04] garyserj: has joined #ruby


[00:00:29] garyserj: Quit: garyserj


[01:15:19] garyserj: has joined #ruby
[03:39:08] garyserj: Quit: garyserj
[03:41:41] garyserj: has joined #ruby
[06:07:24] garyserj: I am having difficulty programmatically sending the ENTER key. I am using IRB (ruby interactive). If I do driver.find_element(:name, "q").send_keys("aaa\n"); it sends the aaa but not the ENTER. If I do driver.action.send_keys("\n").perform. That doesn’t do it either. And if I do \u0006 and \u0007 instead of \n, it still doesn’t work. i’ve also tried b=driver.find_element(:tag_name, "body”); b.send_key “\n”; b.send_keys
[06:07:25] garyserj: “n”; but it hasn’t worked either.
[06:07:56] garyserj: (using Selenium and the firefox browser. sendkeys to the searchbox on
[07:26:27] garyserj: Quit: garyserj
[13:15:59] garyserj: has joined #ruby
[13:28:00] garyserj: Quit: garyserj
[13:32:59] garyserj: has joined #ruby
[14:47:56] garyserj: Read error: Connection reset by peer
[14:49:59] garyserj: has joined #ruby
[14:54:57] garyserj: Ping timeout: 268 seconds
[15:02:24] garyserj: has joined #ruby
[15:32:20] garyserj: Quit: garyserj
[16:06:56] garyserj: has joined #ruby
[16:38:13] garyserj: Quit: garyserj
[17:01:01] garyserj: has joined #ruby
[19:34:53] garyserj: Quit: garyserj
[23:17:03] garyserj: has joined #ruby
[23:35:55] garyserj: Quit: garyserj
[23:40:48] garyserj: has joined #ruby


[15:51:54] garyserj: has joined #ruby
[16:37:40] garyserj: Quit: garyserj
[16:47:49] garyserj: has joined #ruby
[17:31:51] garyserj: has joined #ruby
[17:51:10] garyserj: Quit: garyserj
[19:14:09] garyserj: has joined #ruby
[19:53:58] garyserj: Quit: garyserj


[13:42:43] garyserj: has joined #ruby
[14:01:03] garyserj: I notice that #rails has gone invite only
[14:01:43] garyserj: how can i make 'c' continue in pry-byebug?
[14:01:48] garyserj: why isn't it default anyway?
[14:04:15] garyserj: has joined #RubyOnRails
[14:56:24] garyserj: Ping timeout: 252 seconds


[12:23:57] garyserj: has joined #ruby
[12:28:43] garyserj: i'm having trouble getting pry byebug to work. I did require 'pry' and I did binding.pry, Then I run the program and it pauses, which is good. But I can't get it to step through the code. I tried c/continue, no use. I tried n/next. No use. I tried s/step, no use. I tried 'help' but i don't see a command to step!
[12:39:36] garyserj: ah i think require 'pry-byebug' and binding.pry do it
[13:14:08] garyserj: Ping timeout: 244 seconds


[10:17:05] garyserj: Ping timeout: 248 seconds


[22:59:04] garyserj: has joined #RubyOnRails
[23:00:06] garyserj: hi. i am on macos, my rails version is 5.1.6 How do I update it?
[23:02:33] garyserj: thanks. is there a good way of doing this so that I can still go back to 5.1 if need be?


[16:12:57] garyserj: Ping timeout: 264 seconds


[16:11:30] garyserj: Ping timeout: 244 seconds
[16:12:22] garyserj: has joined #ruby


[20:35:00] garyserj: Like I do rails c and Abc.create a few times to create some records. Then I do git add -A, and git status -s, and I don't see anything listed. It doesn't show any files having changed.
[20:35:00] garyserj: Why doesn't Git detect changes to a database and add them to commits?


[00:47:18] garyserj: rule for when you put .....belongs_to?
[00:47:18] garyserj: I notice that in the case of 1-M you put has_many in one model, and belongs_to in the other one. The one with the foreign key has the belongs_to. Whereas in the M-M case, you put has_and_belongs_to_many in both of them, even though neither has a foreign key. And you do a create_join_table :blahA, :blahB line in the migration file, and that table will have the foreign keys. So what's the
[01:23:35] garyserj: Alec: like the many to many relationship between Car and Driver
[01:24:01] garyserj: where a car can have many different drivers (man, wife, son). And a driver could have many different cars.
[01:25:15] garyserj: you write has_and_belongs_to_many in both Car and Driver. Even though Car doesn't have a foreign key to driver and Driver doesn't have a foreign key to Car. I guess it's because there is a foreign key somewhere (in this case, in a linking table)


[00:14:10] garyserj: has joined #RubyOnRails
[00:17:44] garyserj: in rails, should one be able to see an instance variable in one method when it was created in another method?
[00:17:57] garyserj: i know one can in ruby normally but for some reason i can't see it in rails
[00:26:22] garyserj: here is my code
[00:26:46] garyserj: I go to /qqq then /rrr I expect XaaaX but I get XX


[00:36:57] garyserj: Ping timeout: 240 seconds
[00:37:07] garyserj: has joined #ruby


[16:03:21] garyserj: has joined #RubyOnRails
[16:03:31] garyserj: the GET request?
[16:03:31] garyserj: Is the session dependent on the TCP three way handshake? When I make a new tab I notice that my session variable isn't cleared. Whereas if I start an incognito window in chrome then the session variable clears for that window. And if it is dependent on a three way handshake, then is there a way to tell the browser to not just make a get request, but to make a new three way handshake before
[16:18:01] garyserj: I know about the layers. I'll try to find the cookie.
[16:19:59] garyserj: ah, found the cookie. Thanks!
[16:20:16] garyserj: (I wanted to know how it worked, that was all.. but found the cookie now).


[22:58:37] garyserj: has joined #ruby


[15:15:00] garyserj: Ping timeout: 260 seconds


[03:14:10] garyserj: Ping timeout: 264 seconds
[03:15:03] garyserj: has joined #ruby


[15:12:33] garyserj: Ping timeout: 248 seconds
[15:13:05] garyserj: has joined #ruby


[00:23:41] garyserj: apeiros: thanks, yeah my edit action was treating the number in the edit url as an index to the array, rather than as an id.


[21:45:46] garyserj: has joined #RubyOnRails
[21:47:45] garyserj: why is it that when I go to and submit a form in edit.html.erb then when it goes to /posts/1 when it runs the update action? Why does it increment the id?


[00:15:10] garyserj: Ping timeout: 256 seconds
[00:15:49] garyserj: has joined #ruby


[18:49:28] garyserj: has joined #RubyOnRails
[18:50:13] garyserj: I heard that controller should be plural and model singular, but at this link I see he made the controller singular. Which should it be? Thanks


[02:47:13] garyserj: *.net *.split
[02:47:59] garyserj: has joined #ruby


[21:25:38] garyserj: has joined #ruby
[21:29:19] garyserj: does ruby have a distinction between a)class variables b)class instance variables c)instance variables ?
[21:46:42] garyserj: I heard that if an instance variable is in a class method, then it is a class instance variable
[21:53:46] garyserj: if an instance variable is not class-level, is it local?
[21:54:37] garyserj: okay so when an instance level is not at class level, what is its level?
[21:54:53] garyserj: I mean.. okay so when an instance variable is not at class level, what is its level?
[21:55:20] garyserj: when you say class-level instance variable, isn't that superfluous if you mean that all instance variables are class-level?
[21:56:20] garyserj: okay so are you suggesting that some instance variables are class level and some aren't?
[21:56:40] garyserj: so are some class level and some not? or are they all class level?
[22:02:36] garyserj: why do you keep mentioning class variables though?
[22:02:46] garyserj: when i'm asking about instance variables, and class-level instance variables
[22:02:57] garyserj: are you including "class-level instance variables" as your class variables?
[22:04:39] garyserj: are all instance variables shared among instance methods?
[22:05:15] garyserj: so what causes an instance variable to be 'class level'? is it use of it outside of any methods?
[22:11:38] garyserj: suppose an instance variable is sometimes used in instance methods and sometimes outside of them. Does the fact that it's sometimes used outside of them mean that it is always referred to as a class-level instance variable. Or is it only referred to as a class-level instance variable in the places where it is used outside of instance methods?
[22:26:30] garyserj: ah sorry was afk just reading now
[22:29:40] garyserj: heh, thanks
[22:33:07] garyserj: I know java so I know the difference between static and instance.
[22:34:59] garyserj: You wrote "If you define an instance variable on a thing that is itself an instance of Class," But what defines a variable though.. it seems in ruby you just write a statement like @a=4 and hey presto that defined it, but you may have @a=4 elsewhere. So which one defined it? the one that ran first I suppose?
[22:37:12] garyserj: so if an @ variable is defined outside of methods and within instance methods, then is it class-level or not?
[22:40:34] garyserj: okay so do you think that there aren't two types of instance variables?
[22:41:13] garyserj: class-level instance variables, and instance variables that aren't class-level.
[22:42:05] garyserj: no I mean only @/
[22:42:35] garyserj: I mean @ not @@.
[22:42:45] garyserj: @@ is not an instance variable of any kind.
[22:43:56] garyserj: I don't really understand myself.
[22:44:07] garyserj: I understand what you're saying though.
[22:44:23] garyserj: but some people speak of some instance variables being class-level, so it's more a question for them.
[22:45:26] garyserj:
[22:45:32] garyserj:
[22:45:37] garyserj: that speaks of class instance variables.
[22:46:24] garyserj: "A disadvantage of class instance variables is that they cannot be used within instance methods as class variables can. Another disadvantage is the potential for confusing them with ordinary instance variables. "
[22:46:52] garyserj: so that toptalkedbooks link has a clear distinctio between two types of instance variable
[22:47:50] garyserj: If a class has instance variables, that wouldn't mean we have two types of instance variables though?
[22:48:17] garyserj: that toptalkedbooks link is showing an instance variable within a method to be not class-level, whereas an instance variable outside of a method to be class-level
[22:49:08] garyserj: An instance method used in one method, isn't it completely accessible from another instance method, so same scope?
[22:49:32] garyserj: so are you suggesting there's a scope shared by instance methods, and a scope outside of instance methods, and they're different?
[22:53:26] garyserj: interesting, thanks
[22:54:54] garyserj: what a crazy language
[22:55:38] garyserj: java is so much simpler
[22:56:24] garyserj: in terms of static(non-instance) variables and instance variables. and strictness about where they are defined and their scope.


[00:58:20] garyserj: baweaver, havenwood: thanks


[02:57:01] garyserj: i'm looking at Net::FTP in Ruby. I don't see a copy command to copy from a file from one location on the ftp server, to another. So to copy should I 'get' and then 'put', or is there a better way?
[02:58:25] garyserj: does this chat have a log?
[02:58:32] garyserj: available online


[02:17:43] garyserj: has joined #RubyOnRails
[02:17:53] garyserj: people? I thought the controller should be singular and the table will be plural. Yet it has controller as plural.
[02:17:53] garyserj: I was looking on and it says form_tag({controller: "people", action: "search"}, method: "get", class: "nifty_form") But when try that in my erb file, I get this in my html form_tag(controller: "people", action: "search", method: "get", class: "nifty_form") which is clearly not valid html. Also, should my controller be called person or


[02:03:23] garyserj: What does this mean if 3==3 then "gg" end Like no puts for example.
[02:13:48] garyserj: yes I understand programming languages, but ruby seems a bit different in the statement returning something
[02:14:37] garyserj: suppose I have a function r=def abc1; puts "gg"; end Then can I execute it through r?
[17:29:22] garyserj: Read error: Connection reset by peer
[17:29:36] garyserj: has joined #ruby
[21:33:04] garyserj: Read error: Connection reset by peer
[21:33:17] garyserj: has joined #ruby


[00:19:10] garyserj: lupine, eam: ah, I see, thanks.
[00:30:08] garyserj: not variable width. Though sure if chcp 65001 (utf-8) was set then it would be variable width and i'd expect that would/could affect speed. Great point though about usage of 'b', particularly with unix.
[00:30:08] garyserj: In windows cmd.exe, unicode encodings don't work that well e.g. there is a command chcp 65001 to make things utf-8 but some programs don't work well with it.. So it's common for people to have some variety of 8 bit ascii. So in the uk, chcp 850 or in the us chcp 437. And ruby when 'binary' is not set, runs with whatever codepage is set there. So it should be the same speed 'cos 437 or 850 are


[21:24:38] garyserj: havenwood: thanks
[21:27:49] garyserj: Why is it that when I do"blah.txt","rb"); myFile.gets It interprets the new line. The myFile.gets shows the first line. Whereas isn't "rb" meant to be read-only, and binary. And wouldn't binary mean don't interpret new line? "binary file mode Suppresses EOL <-> CRLF conversion on Windows"
[21:31:51] garyserj: Eiam: extension is irrelevant. and if a file is plain text it's still possible to read it as one reads a binary file
[21:32:02] garyserj: isn't about executing instructions
[21:32:57] garyserj: jordanm: so on unix it leaves \n as \n and in windows it converts \r\n to \n. ?
[21:33:33] garyserj: yeah, thanks
[21:34:52] garyserj: yeah, \r\n to \n if you don't use it
[21:36:27] garyserj: it looks like 'b' on windows (and presumably unix), does nothing. But the default is in windows when ruby reads a file it converts \r\n to \n
[21:36:45] garyserj: and 'b' leaves the file as it is so stops ruby doing that conversion.
[21:37:41] garyserj: if I wanted to treat new lines not as new lines but just as characters I suppose I could use .read instead of .open
[22:49:12] garyserj: eam: do you have any practical example that shows that 'b' interprets the encoding differently?
[22:56:14] garyserj: encoding as specified then one can be even more sure that the 'b' or lack thereof is not influencing the encoding.
[22:56:14] garyserj: I've noticed that "rb" can show an encoding of ASCII-8BIT and "r" can show it as CP850 but I don't see a difference.. and CP850 is a subset of ASCII-8BIT. Also one can specify an encoding e.g."blah.a","r:ASCII-8BIT") or"blah.a","r:CP850") or"blah.a","rb:ASCII-8BIT") or"blah.a","rb:CP850") so when it even reports the same
[22:56:40] garyserj: a=myFile.gets;


[02:05:41] garyserj: hays: yes I thought of that too, that's a good idea
[02:09:03] garyserj: hays: do you think it matters what A,B,yyy,zzz are?
[02:09:21] garyserj: it's not to do with testing something that would or could be in the URL anyway.
[02:09:33] garyserj: so it's not like more routes would make a difference.
[02:10:27] garyserj: hays: with three ifs, I think so. With the extra nesting I don't think so.. though we disagree there with the latter.
[02:12:23] garyserj: baweaver: you accused me of trolling as if i'm trying to provoke this conversation with you about goto further but i'm not.
[02:15:07] garyserj: hays: spaghetti like and nested ifs are very different things.. nested ifs, while they can be ugly, are technically not spaghetti code.
[02:15:23] garyserj: spaghetti code would be Gotos jumping all over the place.
[02:15:39] garyserj: no gotos and it may still be ugly though technically not spaghetti code, just ugly code ;-)
[02:19:05] garyserj: you could flatten nested ifs into multiple ones with longer conditionals.. How are you solving that with more methods?
[02:19:32] garyserj: hays: yeah I don't think there is any getting around logic like that.
[02:19:42] garyserj: methods have nothing to do with it
[02:22:02] garyserj: well, iirc the example I had was.. get '/' do then check params[:g].has_key?(:tempfile) (that was condition A). if it does then test if the file ends in .htm or .html. (That was condition B).
[02:22:37] garyserj: baweaver: nobody is suggesting not using methods and nobody is suggeseting having 100 lines of code not broken into a different method.
[02:23:07] garyserj: methods have nothing to do with this, it's a complete red herring
[02:23:20] garyserj: hays: I agree
[02:31:49] garyserj: baweaver: that doesn't make sense. in my case I have a form, they select a file and click submit. It makes a request, to one route.
[02:32:05] garyserj: the problem isn't solved by multiple routes.
[02:32:36] garyserj: well you keep being very presumptuous about the code
[02:32:47] garyserj: and each time, wrongly.
[02:33:19] garyserj: And now that you know more about it, can you tell me how my simplified example that I gave you, changes whatever solution you haven't come up with?
[02:34:09] garyserj: you were incorrect when you said you could solve it with more methods, and incorrect when you said you could solve it with more routes. So now you know more, how would you solve it?
[02:34:37] garyserj: I think what hays said, of flattening the ifs, is perfectly good. And totally based on my simplified example.
[02:35:05] garyserj: adding all that detail you wanted hasn't helped anybody.
[02:35:53] garyserj: and you still accuse me of trolling? I only continued the discussion with you because you kept requesting that I continue it.
[02:40:04] garyserj: i think that is the ugliest!
[02:42:19] garyserj: way way back I learnt the harm of over-modularisation
[03:53:41] garyserj: somebody might make a response e.g. there is a paper called "goto statements considered harmful, considered harmful"
[14:16:16] garyserj: hays: that link just has dijkstra making his case that frank rubin is a bad programmer. IF you look at the example in the second answer here It is *Exactly* the usage I used.. which is described as a good use of Goto.
[14:29:10] garyserj: hah, linus should've written the goto statements considered harmful considered harmful paper!