#ruby - 02 December 2017
« Back 1 day Forward 1 day »
[11:28:07] c_nick: hi .. how to retrive only two columns of a specific table using Active Record- Active Relations (Ruby not rails) .. i can go Table.where(run_id: 1) but this will return me the whole row ..
[11:31:48] apeiros_: c_nick: even if you use AR outside of rails, it's still a part of rails and the people knowing about it are in #rubyonrails ;-)
[11:32:46] c_nick: active record is a design pattern .. Arel is also not rails specific i suppose but I guess you are right most people are in rails on this
[11:41:17] c_nick: apeiros, sorry one last question i know that we can do AR.pluck(:id) will give us [1,2,3] but what will AR.pluck(:id,:name) give us ?
[11:45:29] apeiros: hence plain irb doesn't need rails. and irb comes with a standard install of ruby.
[11:46:55] apeiros: if you haven't actually yet used it outside of rails, ActiveRecord::Base.establish_connection is the method you're looking for
[11:47:26] apeiros: with pry, you can put a .pryrc in your project which contains code pry should execute at startup. ideal for stuff like establishing a connection f.ex.
[14:43:32] TomyLobo: i have a ruby data structure consisting of a nested hierarchy of hashes, arrays, strings, and numbers
[14:47:22] TomyLobo: (this is dpath: http://search.cpan.org/~schwigon/Data-DPath-0.57/lib/Data/DPath.pm )
[16:41:41] al2o3-cr: how to do you correctly deal with structs within struct using the ruby stdlib fiddle?
[16:48:45] al2o3-cr: this might give you a better idea of what i'm on about: https://gist.github.com/gr33n7007h/651ef33ff52b573612473a375cf49085
[18:12:33] odinsbane: I am trying to install mysql2 gem with bundle. I get an error, that has a workaround here, https://github.com/brianmario/mysql2/pull/857 but I don't know how to update the header file and have bundle use that file.
[18:39:53] RickHull: if there is a fork or PR that you can checkout locally, you should be able to build the .gem locally
[18:40:23] RickHull: and then you can host the .gem with e.g. geminabox, or just copy it to the target system
[18:40:25] odinsbane: It appears the fix is pretty trivial, just add an include into the header file.
[18:42:27] RickHull: you'll have to dig into the specifics what the result of this ticket is to find the simplest path forward, but build-it-yourself is always a fallback
[19:19:04] odinsbane: If I want to update a gemfile to use rails 4.2.xx how would I do that? bundle update put it at 5.1.xx something.
[19:20:14] RickHull: paste the Gemfile -- it should be quite straightforward to specify a version for the rails gem
[19:35:51] RickHull: for the record, I haven't used bundler in depth in many years -- so anyone else may have better and more specific advice
[19:40:48] odinsbane: I changed the rails version to be "~>4.2.0" and did a bundle update, so now it is installed as rails 4.2.10 and I think now I am just going through rails issues.
[20:10:56] odinsbane: It's brutal, I can't install ruby 2.3 or lower because of openssl 1.1 with fedora. Rails 4.0 doesn't work with ruby 2.4.
[20:14:59] odinsbane: Yes, I am just fumbling along with all of these versions, trying to find the best way to get things resolved.
[20:16:13] odinsbane: I built ruby with a local copy of openssl, but then when I built gems they used the system version. No I didn't try rvm yet.
[20:18:51] odinsbane: If you try to build ruby 2.3.5 with fedora and the openssl-devel package installed, it will fail.
[21:50:39] havenwood: bozozo: Hmm. Underscore often means private but I don't know of a context where it's a wildcard.
[21:51:14] bozozo: ok thanks. maybe I got bad info. That explains why I couldn't find it anywhere else
[21:51:15] havenwood: Prefixing with underscore generally means private or in Ruby it means an unused local variable.
[21:51:30] darix: RickHull: you want to update rails 4.0 anyway ... you know security ;) ... I doubt many people go through backporting fixes ;)
[22:23:59] lisita: apeiros: I'm trying to make a very simple program that's basically a REPL. You type 'up' and it runs system 'adb shell input keyevent somenumber'. Here's a simplified snip of what I'm doing https://paste.fedoraproject.org/paste/rtUwyB7mhlZ76ZlaAQHaDA . I'm wondering if I could use a function to do the same thing or something else that's less lines of the same code.
[22:31:57] lisita: TomyLobo2: That does make more sense but I'm really really trying to use ruby in any silly way possible. :)
[22:32:15] joelwallis: Hi. I'm working on a new Jekyll theme, which are defined as a gem. However, I couldn't figure how the development workflow works. There's no enough documentation about it, and the Jekyll website just suggests that 'you can add dummy content to your template files' (WTF?)
[22:32:54] joelwallis: Something like: gem: "jekyll-theme-mytheme", local: "../jekyll-theme-mytheme"
[22:34:48] RickHull: lisita: you would probably want to make each command a function, with definitions above the loop. could be anonymous functions, a module, or a class
[22:36:55] joelwallis: RickHull: nope. I'm creating it from scratch (jekyll new-theme jekyll-theme-mytheme)
[22:36:57] RickHull: lisita: when calling system, call it with several args rather than a string with embedded whitespace. e.g. system(command, arg1, arg2 ...)
[22:38:02] joelwallis: it will be a pretty basic theme. I just can't figure how to visualize my code while working on it
[22:39:59] Flashynuff: hi there! i'm having some trouble running a ruby script as a rake task (context: the ruby koans). I'm really not sure what's going wrong since it was working perfectly fine on this computer a few months ago when I last worked on it. Right now it just gives me 'Command failed with status 127'.
[22:40:03] Flashynuff: Here's the Rakefile I'm trying to run https://hastebin.com/iverecijud.rb and the output of rake --trace https://hastebin.com/raw/bacujijexo. I haven't been able to find any solutions online, any ideas? I've already tried uninstalling/reinstalling rake
[22:40:04] RickHull: lisita: check the return value of system to know if the command failed. you might just print a helpful message and exit
[22:41:17] RickHull: this looks pretty weird to me: C:\Ruby23\bin;C:\Ruby23\DevKit\dk.rb path_to_enlightenment.rb
[22:42:19] RickHull: ok, looks like yes, jekyll themes are organized as gems https://jekyllrb.com/docs/themes/
[22:45:23] RickHull: Flashynuff: I would guess something is messed up in your PATH or whatever alias to the ruby.exe
[22:45:55] RickHull: instead of calling ruby.exe as expected, rake.exe wants to call C:\Ruby23\bin;C:\Ruby23\DevKit\dk.rb
[22:47:29] RickHull: Flashynuff: instead of `ruby arg1, arg2, ...` you can call `sh 'ruby', arg1, arg2 ...`
[22:49:44] Flashynuff: i had an environment variable called RUBY to store C:\Ruby23\bin;C:\Ruby23\DevKit\dk.rb so i could put in my PATH... I just renamed it to RUBY_PATH and it started working
[22:58:39] lisita: What are good resources to learn the oop concepts of ruby? I saw this https://launchschool.com/books/oo_ruby, but I need something a bit more complete.