#ruby - 31 December 2017
« Back 1 day Forward 1 day »
[11:47:57] mynameisdebian: Anyone use Rails? Looking at the example at the bottom of this page on Controllers here: https://www.tutorialspoint.com/ruby-on-rails/rails-controllers.htm What is the practical difference between the "show" and "edit" methods? Are they both needed?
[12:00:19] mynameisdebian: mozzarella: Thank you for the reply. Can you elaborate on that for me? The only difference I see is that "edit" includes the line "@subjects = Subject.all"
[12:01:08] mynameisdebian: mozzarella: I guess I don't see how the edit method actually changes anything?
[12:01:56] mozzarella: mynameisdebian: it doesn't change anything, it's from there that you write the form needed to modify an entry
[12:05:40] mozzarella: mynameisdebian: maybe you would understand better by looking at the screenshots: https://www.tutorialspoint.com/ruby-on-rails/rails-views.htm
[12:06:24] mynameisdebian: mozzarella: tbh I was just going through that tutorial in order, and I didn't get to the Views section yet, so didn't realize that I would be defining a view for each method (I get that now)
[12:18:45] leitz: Confused again. Didn't we used to be able to declare a variable outside of a method and then use it in the method, as long as it wasn't re-defined?
[12:22:37] mynameisdebian: leitz, if you are not defining a class in your .rb file, try preceding the variable with an '@'
[12:23:27] mynameisdebian: leitz, sorry, I may have misunderstood. Can you paste your code somewhere?
[12:27:19] leitz: mynameisdebian, Line 19 sets the connection name. L43's method needs it https://github.com/makhidkarun/rb_tools/blob/master/bin/set_origin_planet.rb
[12:28:05] leitz: Lately I've moved back to Ruby from Python, so I may just be more confused than normal.
[12:30:24] leitz: The code and connection work. I was just wondering if there was a way to not pass in the connection name.
[12:32:17] mozzarella: I don't think it ever was possible, but you can use globals, constants or functions
[12:32:27] tomlukeywood: I am attempting recursion in ruby yet when i try this code i get an error: quiz.rb:19: syntax error, unexpected tIDENTIFIER, expecting keyword_end
[12:32:28] ruby[bot]: tomlukeywood: we in #ruby do not like pastebin.com, I reposted your paste to gist for you: https://gist.github.com/c70e92a3d9458ac9d8980ec74e4e5178
[12:32:29] ruby[bot]: tomlukeywood: pastebin.com loads slowly for most, has ads which are distracting and has terrible formatting.
[12:34:54] mynameisdebian: tomlukeywood, I'm not a Ruby expert but can you define an argument list without commas?
[12:46:57] leitz: Hey tomlukeywood, I've done one or two small recursion exercises. Literally, one or two. So I get the concept of it but not much more. Reading "Grokking Algorithms" and it's helping. Took a coding break for the past couple weeks.
[12:47:59] leitz: Also re-reading "think like a programmer" and the recursion example makes sense. Mostly.
[12:57:18] jhass: havenwood: al2o3-cr I maintain a couple of the older ruby packages but the main one is by anatol
[13:37:37] troulouliou_div2: hi i have a string like this BLAH=DATA1, BLAH2=DATA2, BLAH3=DATA3 ; what is the best way to extract DATA3 with a regexp ?
[13:38:02] troulouliou_div2: i can get the index of BLAH3 and then extract but i would like to know if there is a better way
[13:42:35] lupine: `match` will return a MatchData instance. you can get by index (1 being the first capture group) or do whatever else you like
[15:36:06] ikopico: yo, in gemspec - adding 'rake' and 'rspec' as 'add_development_dependency' - then running with 'bundle exec' tells me that I don't have 'rake' installed in this bundle, same goes with rspec. I guess this is a common misunderstanding, can anyone please advise?
[15:38:41] havenwood: ikopico: I just tried a two-liner Gemspec with rake as dev dep in gemspec and it installed rake.
[15:46:58] ikopico: OK I'm feeling dumb now, I've removed the .bundle dir and refetched everything ¯\_(ツ)_/¯
[15:47:36] ikopico: Thanks a lot havenwood - in the future when in doubt I'll first turn it off and on again
[19:11:56] havenwood: TomyLobo2: Here's an example solution with ai4r: https://github.com/SergioFierens/ai4r/tree/master/examples/genetic_algorithm
[19:13:14] TomyLobo2: that thing's page was redirecting to all kinds of advertisement so i didnt look into it
[19:21:13] TomyLobo2: i made a savegame parser, i'm picking it apart to find all the planets missing research/mining stations, now i want to find the optimal route between them
[19:25:53] TomyLobo2: yeah i just have to make sure i dont have all permutations in memory at any point ^^
[19:28:00] TomyLobo2: maybe i should use backtracking instead of being lazy and using Array#permutation
[22:02:33] apeiros: I mean, assuming calculating 1 takes 1µs (0.000001s), you still wait for 11 years…
[22:11:06] capin: would anyone mind taking a look at a homebrew formula I have edited, https://goo.gl/nEx1Fs I can't figure out why the app won't compile with python support. more specifically why cmake can't find a library even though I've added the library path as a compile time arg. build error => https://goo.gl/c1r6F9
[22:20:19] TomyLobo2: looks like that would get more replies in a channel about whatever that "homebrew formula" thing is
[22:26:29] capin: TomyLobo2: yeah I posted in #machomebrew yesterday, and there hasn't been a reply since my post from yesterday ¯\_(ツ)_/¯
[23:44:06] _sfiguser: hello guys... is there something similar to urllib3 in ruby ? http://urllib3.readthedocs.io/en/latest/user-guide.html