#ruby - 06 November 2018
« Back 1 day Forward 1 day »
[08:37:36] ntt: Hi, I'm trying to use Devise and I'd like to know if it is possible to use current_user in before_action? basically I added an attribute (.admin) to the model User, and I'd like to use something similar to "before_action current_user.admin?". Please, someone can give me some advice? Thank you
[08:43:15] ntt: tbuehlmann: actually I have an error: "undefined local variable or method `current_user' for ContractCategoriesController:Class". My syntax is: "before_action current_user.admin?, except: [:show, :index]"
[08:52:47] ntt: tbuehlmann: I'm trying but it seems that if my private method in the application controller returns false, before_action doesn't consider this
[08:55:16] ntt: if the private method returns false, I'd like that CRUD actions will not be permitted
[08:57:22] tbuehlmann: returning false doesn't do anything. you need to render or redirect in order to avoid running the action
[08:57:39] tbuehlmann: it's in the example on https://guides.rubyonrails.org/action_controller_overview.html#filters
[14:34:22] havenwood: Bish: You could run unicorn with `rackup`, but then it'll just be the path to rackup executable. If you put `PROGRAM_NAME = $0.dup` in http_server.rb, you could get at that, but again it'd be path to the unicorn executable.
[14:46:32] havenwood: Bish: Maybe something like: %w[client_api_server rackup unicorn].include? File.basename $PROGRAM_NAME[/\A\S+/]
[17:29:37] craftytech: hello folks: does anyone know how to start puma server in debug mode? Is it something configured in puma.rb??
[18:17:46] za1b1tsu: Hello, do I have to run rubygems-bundler for each ruby version I have installed?
[18:29:55] havenwood: za1b1tsu: You can use rubygems-bundler outside of RVM, but I don't. I guess I just like explicit more than I dislike typing `bundle exec`.
[19:55:10] fiftysix: i just noticed writing "private def foo; end" compiles, so it's not illegal. but does it mean "make method foo private"? or does it still make all following methods private?
[19:57:07] mochiyoda: just that one. def returns a symbol, so you're just making that method private ala: "private :foo"
[19:57:12] voelzmo: Hey, not sure where to ask this, so maybe someone knows where to better address this: We have been programmatically trying to figure out if a new version of ruby has been released by looking at http://cache.ruby-lang.org/pub/ruby/index.txt but it seems it hasn't been updated for e.g. 2.4.5. Any reason or any better way to check for new ruby versions and get their link+sha?
[20:15:18] havenwood: voelzmo: One option would be to use the ruby-versions repo, which ruby-install consumes for Ruby metadata: https://github.com/postmodern/ruby-versions
[20:16:34] havenwood: voelzmo: A while ago I needed something similar, and used the FTP mirror to get at it: https://gist.github.com/havenwood/4395461
[20:16:44] kaleido: what's the current favorite web micro framework? and sorry if this is off topic.
[20:17:21] havenwood: voelzmo: ruby-versions has the md5, sha1, sha256 and sha512 - and the dl url can be composed from the version
[20:18:26] havenwood: kaleido: If you want something more Rails-inspired, Hanami is another nice option: https://hanamirb.org/
[20:18:46] havenwood: kaleido: I love Roda's simplicity, being just a routing tree with optional plugins: http://roda.jeremyevans.net/
[20:19:29] voelzmo: @havenwood as a bonus question: do you have any idea what happened to updating http://cache.ruby-lang.org/pub/ruby/index.txt
[20:20:22] havenwood: voelzmo: I don't know why it doesn't always get updated. I think this has happened before. I'm not sure what's the matter.
[20:21:54] voelzmo: okay, thanks. We'll just switch to https://github.com/postmodern/ruby-versions and update our CI
[22:09:54] havenwood: biberao: here are a few books: https://gist.github.com/baweaver/57a7c8296ca2c03effbd8fac1e7f6b40#learning-ruby
[22:11:16] havenwood: biberao: If you're familiar with REPLs, Ruby has great ones. I'd suggest getting started with irb or pry early.
[22:11:19] ruby[bot]: irb is "interactive ruby", it is part of ruby. You can run ruby code and see results immediately. it's useful for testing code. Also see ?pry, a gem which is a popular alternative to irb.
[22:11:21] ruby[bot]: Pry, the better IRB, provides easy object inspection `ls`, `history`, viewing docs `?`, viewing source `$`, syntax highlighting and other features (see `help` for more). Put `binding.pry` in your source code for easy debugging. Install Pry (https://pryrepl.org/): gem install pry pry-doc