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
2
votes
1 answer

Does ArgumentError lack backtrace_locations?

When I call Exception#backtrace_locations, it usually returns an array, as intended: begin raise "foo" rescue => e p e.backtrace_locations end # => ["this_file:2:in `
'"] This is the same if I raise an ArgumentError manually: begin raise…
sawa
  • 165,429
  • 45
  • 277
  • 381
2
votes
2 answers

Why does code written in Ruby 2.1 have to be parsable by Ruby 2.0 interpreter?

In Ruby Core, a new literal notation "foo"f for frozen strings have been proposed for Ruby 2.1, but now people are concerned that code written in such syntax would not be parsable by Ruby 2.0. Why is that an issue? Hasn't Ruby tried to be only…
sawa
  • 165,429
  • 45
  • 277
  • 381
2
votes
1 answer

Why should a literal String start out Frozen? (Ruby 2.1)

Following development of Ruby 2.1 I have read about a feature that will probably be added so a developer is allowed to specify that a literal String should start out "frozen". The syntax looks like this (note the trailing f): str = "imfrozen"f #…
CharlesHorse
  • 449
  • 1
  • 4
  • 9
1
vote
1 answer

undefined method `find_all_by_X'

Currently maintaining some old Ruby server and got the following error in Log: NoMethodError (undefined method `find_all_by_X_ID' for #): app/controllers/some_controller.rb:10:in `buggy_function' When viewed the faulty…
1
vote
1 answer

ruby convert string private key back to openssl class for encryption

I have a situation where the private key is stored as a string in the database. > private_key > => "-----BEGIN RSA PRIVATE…
Micheal
  • 2,272
  • 10
  • 49
  • 93
1
vote
1 answer

backward-compatibily code for ruby 1.8 and ruby 2.1 not working on File module

I need to write some code that need to run on ruby 1.8 and ruby 2.1, and specifically opening a file in UTF-8 encoding, so I naively wrote that if RUBY_VERSION > "1.9" f = File.open('/usr/share/hwdata/pci.ids', encoding: "utf-8") else f =…
Baptiste Mille-Mathias
  • 2,144
  • 4
  • 31
  • 37
1
vote
1 answer

SQLite3::SQLException: no such function: REGEXP rails rspec

In my project, I have different time slices. These time slices have names such as "00-04", "04-08", "08-12", "12-16", "16-20" and "20-24" and more. I wanted to get all the time slices objects with aforementioned names. So, I programmed…
Sadiksha Gautam
  • 5,032
  • 6
  • 40
  • 71
1
vote
0 answers

Redirect a url with only some get params in Rails 4

I am developing an application that should still respond to some old urls from a previous web application. I would like to build some redirects to an action only when a param(get param) is present. for instance get '/students/:id?school_id=(:id)',…
anyavacy
  • 1,618
  • 5
  • 21
  • 43
1
vote
0 answers

ActionMailer User object injection

This is frustrating me. For some reason, whenever we are sending an email, ActionMailer insists on checking the User model for a user with that email address. We have the method defined like this: class MonitorMailer < ActionMailer::Base default…
1
vote
0 answers

How to develope two rails app in single root directory?

The problem description is as : I have an existing app. developed in php. I have to transform that in rails. I have to develop enterprise version of same point 1 app. with additional functionality and complexity for enterprise related work . I have…
1
vote
1 answer

passenger with apache error "Could not download..."

I'm use: Ubuntu Ubuntu 15.04 x64, Ruby 2.1.4, Rails 4.2.3, Passenger 5.0.0.rc2 or later tryed, Apache 2.4.10. I can't start project in production, because recieve the error: [ 2015-08-24 10:40:53.2503 3427/7fc8ed450700…
shilovk
  • 11,718
  • 17
  • 75
  • 74
1
vote
3 answers

Rails 4 newbe : Routing Error -

I am very new to rails. No idea how to fix it. I cannot even start a simple rails app! Environment: Windows 7 Ruby 2.1.0 Rails 4.2.3 First: I ran generate command D:\railprojects\blog>rails generate controller Pages index routes.rb …
Khoga
  • 857
  • 2
  • 8
  • 26
1
vote
1 answer

Only one image getting uploaded multiple times

I have been using mechanize gem to scrape data from craigslist, I have a piece of code that uploads multiple image to craigslist, all the file paths are correct, but only single image gets uploaded multiple times what's the reason. unless…
codemilan
  • 1,072
  • 3
  • 12
  • 32
1
vote
1 answer

resque rake task giving error

I have been using resque for background processing, No my problem with code is : - when I start rake task as "rake resque:work QUEUE=''" as per ryan bates episode no. 271. in remote server the code inside worker class for file maipulation works…
codemilan
  • 1,072
  • 3
  • 12
  • 32
1
vote
1 answer

superclass must be a Class in rspec after ruby upgrade

I have a class that looks like this: module API module MyNamespace class Base < ActiveRecord::Base end end end module API module MyNamespace class MyClass < Base end end end When trying to upgrade from ruby 1.9.3 to 2.1.5,…
DVG
  • 17,392
  • 7
  • 61
  • 88