Questions tagged [ruby-2.1]

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

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. Ruby 2.1 was released on Dec 25, 2013.

For information on Ruby in general, visit .

222 questions
1
vote
1 answer

generate random number for every 5 seconds in Ruby

random = Random.new.rand(1..50) puts random This code keep generating a random number for every milli seconds. i want to generate a random number for every 5 seconds . something like this, random = (Random.new.rand(1..50), 5000) where 5000…
rinold simon
  • 2,782
  • 4
  • 20
  • 39
1
vote
1 answer

IO#ioctl mangling an argument ? (Ruby 2.1.3)

It seems IO#ioctl alters 2nd argument passed. require "socket" SIOCGIWESSID = 0x8B1B IW_ESSID_MAX_SIZE = 32 sock = Socket.new(Socket::AF_INET, Socket::SOCK_DGRAM, 0) template = "a16pI2" iwessid = [ 'wlan0', ' ' * IW_ESSID_MAX_SIZE,…
David Unric
  • 7,421
  • 1
  • 37
  • 65
1
vote
1 answer

Is there official documentation for `alias` in Ruby 2.x?

I can't seem to find any documentation for Ruby's alias keyword in Ruby 2. I can find lots of non-official pages that talk about it, but nothing official. Is there an RDoc or something for alias? Note: I'm not talking about alias_method, which does…
Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
1
vote
1 answer

Definition syntax with else statement in Ruby 2.1.1

Will ruby support a syntax with the following code: class Test def test #some code here else #some code here end end I found this syntax to be valid and ruby interpreter did not flag any exceptions for this. If this is valid can anyone…
Suhas Giriraj
  • 242
  • 2
  • 11
1
vote
0 answers

Why are there missing file names and lines in Ruby 2.1's ObjectSpace.dump_all heap output?

I recently profiled a bunch of Ruby 2.1.2 code using the new ObjectSpace.dump_all method. I got back some useful data (using the script that @tmm1 suggests in that link): 931…
subelsky
  • 405
  • 6
  • 12
1
vote
1 answer

Can't build native extensions with ruby 2.1.2

I'm on Ubuntu 14.04.1 LTS (Trusty). I use rvm 1.25.28 (stable). When I want to install a gem that is a native extension, it fails with ruby-2.1.2 but works fine with ruby-2.0.0-p481. I can't find anything similar to my issue (make: .//install:…
Micka
  • 1,648
  • 1
  • 19
  • 34
1
vote
0 answers

Bundle Install trying to install gem not in Gemfile

I have a strange problem. I cloned a working rails repository from github. It had a gemfile with certain gems and "debugger" was not one of them. However when i ran "bundle install" it error out An error occurred while installing debugger…
swordfish
  • 4,899
  • 5
  • 33
  • 61
1
vote
1 answer

Ruby combining two arrays causes process to run out of memory

Combining two arrays of hashes that have 100k items each causes a process running on a 2GB VM to run out of memory. I'm failing to understand how/why. Let's say I have a Hash like this and I populate it with 50 key/value pairs. h = {} 1..50.times{…
user1032752
  • 751
  • 1
  • 11
  • 28
1
vote
2 answers

Unable to include shoulda tests in a module

I am using Rails with MiniTest and have several classes that are all related through inheritance. I would like to reuse tests by placing them in a module. Something like this: module MyModule should 'work' do assert true end end Then in…
Tom Rossi
  • 11,604
  • 5
  • 65
  • 96
1
vote
1 answer

Spree: Create new asset failure

I am trying to create a custom form for a third role in Spree 2.3 (Designer). The designer creates a new product and variant, then uploads an image for that variant. My efforts have so far been in vain. How can I create a new asset for a…
steel
  • 11,883
  • 7
  • 72
  • 109
1
vote
2 answers

Rails not updating record and shows no errors even when I know there is at least one

model class Clip < ActiveRecord::Base validates_length_of :description, maximum: 160 end controller def update @clip = @film.clips.find_by_permalink(params[:id]) respond_to do |format| if @clip.update(clip_params) …
rmagnum2002
  • 11,341
  • 8
  • 49
  • 86
1
vote
1 answer

Using attribute in index array method to find index always returning nil in Ruby?

Here is a simple index search based on an instance attribute for an array element: chips = [Chip.new(:white), Chip.new(:black)] color = :white idx = chips.index { |chip| chip.color == color } This always returns nil no matter what values are in the…
Pori
  • 696
  • 3
  • 7
  • 18
1
vote
2 answers

New RSpec runs but never gets to models

I am currently running rspec with rails 4.1.1 and ruby 2.1.1 however I'm getting a bunch of errors related to gems and such with out it even getting to the models. This is a new version of rspec that has a spec_helper.rb as well as a…
Yaron
  • 610
  • 6
  • 13
1
vote
1 answer

Rails 4 and Jammit routing issue - should not use match

I've upgraded to Rails 4.0.5 and i'm using Jammit 0.6.6. When starting the server i get an error : /home/haimh/.rvm/gems/ruby-2.1.0/gems/actionpack-4.0.5/lib/action dispatch/routing/mapper.rb:191:in normalize_condition!:You should not use the match…
Haim Hamou
  • 121
  • 4
1
vote
1 answer

Convert from ISO-2022-JP-2 to UTF-8 in Ruby 2.1

I have a ISO-2022-JP-2 string and need to convert it to UTF-8, but I am getting an error. To be more concrete: I am trying to read an email which is transferred using quoted-printable. This email contains the word tōtatsu (notice the accent above…
Mark Gaensicke
  • 504
  • 5
  • 16