Questions tagged [ruby-2.3]

For issues relating to development in Ruby, version 2.3. If your question applies to Ruby in general, use the tag [ruby].

Ruby 2.3.0 was released on on 25 Dec 2015. It is the first stable release of the Ruby 2.3 series.

It introduces some new features (like the safe navigation operator and frozen string literals) and various performance improvements. A description of new features in Ruby 2.3 is at https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/.

This tag is intended for questions specific to version 2.3 of Ruby.

164 questions
4
votes
1 answer

best way to organize a long piece of code in ruby refinement block

module Access def last self[-1] end def start_end self[0] + last end end module StringExt refine String do include Access end end using StringExt puts 'abcd'.last # => d puts 'abcd'.start_end When a class being…
4
votes
2 answers

NilCheck fix on safe navigation operator (&.)

This simple method on a class just run the status method using the safe navigation operator. def current_status account&.status end But reek report this warning: MyClass#current_status performs a nil-check…
AndreDurao
  • 5,600
  • 7
  • 41
  • 61
4
votes
0 answers

Memory leak in Ruby on Rails app as garbage collector activity spikes

Framework: Rails 5.0.0.1 Platform: Heroku Server: Puma, 30 processes with 10 workers each We're seeing an increase in memory once an hour, coinciding with the Ruby garbage collector as can be seen in the screenshot linked to below. The number of…
Carl
  • 41
  • 3
4
votes
2 answers

miniruby Permission denied Error occurred when installing ruby 2.3.1 using rbenv installed homebrew

I got error message when installing ruby 2.3.1 using rbenv. My environment is below. MacOS 10.10.5 rbenv 1.0.0 The log message is below. $ rbenv install 2.3.1 ... Last 10 log lines: compiling enc/unicode.c compiling enc/utf_8.c compiling…
ima0123
  • 85
  • 1
  • 10
4
votes
3 answers

What is an idiomatic way to measure time in Ruby?

This is pretty ugly: t = Time.now result = do_something elapsed = Time.now - t I tried this: elapsed = time do result = do_something end def time t = Time.now yield Time.now - t end This is better. But the problem is that result falls out…
B Seven
  • 44,484
  • 66
  • 240
  • 385
4
votes
5 answers

error installing ruby 2.3 on osx

I'm getting an error while trying to install 2.3 ruby on osx I've updated rvm to stable 1.27.0 then I'm trying to install 2.3 % rvm install 2.3 ruby-2.3.0 - #removing src/ruby-2.3.0 - please wait Searching for binary rubies, this might take some…
Elmor
  • 4,775
  • 6
  • 38
  • 70
4
votes
1 answer

How to start Rack application with frozen string literals?

I'm trying to run our application under ruby 2.3 using the new ruby feature for automatic frozen strings turned on globally. (Ruby 2.3) This is normally done by passing the argument to a ruby script when starting as follows: ruby…
Oeste
  • 1,041
  • 2
  • 7
  • 13
4
votes
2 answers

Syntactic sugar for Safe Navigation operator(&.)

str = "Hello World!" str.[] /Hello/ # => "Hello" str[/Hello/] # => "Hello", syntactic suger version str = nil str&.[] /Hello/ # => nil str&.[/Hello/] # => SyntaxError: unexpected '[', expecting '(' str[/Hello/] # => NoMethodError:…
sbs
  • 4,102
  • 5
  • 40
  • 54
3
votes
1 answer

Error while installing Rmagick gem on Heroku

I am trying to deploy Rails 4 app to heroku, but installing Rmackick gem fails. Tried buildpacks, but lo luck. got this error: remote: Gem::Ext::BuildError: ERROR: Failed to build gem native extension. remote: remote: current…
user1136228
  • 967
  • 9
  • 22
3
votes
1 answer

Rails generate not working on a existing application

I cloned a rails project from github and trying to run rails generate rspec:install after running bundle install. The console gives following `Usage: rails new APP_PATH [options] Options: -r, [--ruby=PATH] #…
2ank3th
  • 2,948
  • 2
  • 21
  • 35
3
votes
1 answer

Failure of Ruby case equality operator ===

I have: require 'date' pap1 = Date.parse('1968-06-12') pap2 = Date.parse('1968-12-31') dat = Date.parse('1968-06-12') dat2 = dat + 5 # => # In the example below, I want to test if a date falls in a…
3
votes
1 answer

Convert hash params into instance variables on Ruby initializer

I have this class: class PriceChange attr_accessor :distributor_id, :product_id, :value, :price_changed_at, :realm def initialize(data = {}) @distributor_id = data[:distributor_id] @product_id = data[:product_id] @value …
Leantraxxx
  • 4,506
  • 3
  • 38
  • 56
3
votes
3 answers

Why is this switch statement not working?

I have this code (1..50).each do |num| case num when num % 4 == 0, num % 6 == 0 puts 'Cluck' when num % 4 == 0 puts 'Cluck Cluck' when num % 5 == 0 puts 'Cluck Cluck Cluck' else puts num …
JoshEmory
  • 644
  • 6
  • 20
3
votes
3 answers

Ruby 2.3.3: Weird Tempfile.new([name, prefix]) basename converted to hash

Testing an upgrade to Ruby 2.3.3 for our Rails 3.2.22.2 application, and getting a weird situation where we are passing an array as the first argument to Tempfile.new, but it's ending up as a hash. I've patched tempfile.rb to output the basename…
bschaeffer
  • 2,824
  • 1
  • 29
  • 59
3
votes
2 answers

How to confirm a JavaScript popup using Nokgiri or Mechanize

I'm running a script that will open up on my localhost. My local server is a vulnerable web app test suite. I'm trying to confirm a XSS popup from a JavaScript alert. For example: http://127.0.0.1:65412/v?=0.2 I need…
papasmurf
  • 303
  • 3
  • 9
1
2
3
10 11