For issues relating to development in Ruby, version 2.4. If your question applies to Ruby in general, use the tag [ruby].
Questions tagged [ruby-2.4]
73 questions
0
votes
1 answer
Ruby on Rails - after rails_s is entered
I am learning Ruby on Rails and still unfamilar with some of parts of the language.
I am trying to get a rails project to display on Firefox however as soon as I enter the command "rails s" I am presented with the following error:
Rails S Error …

khush
- 1
- 1
0
votes
0 answers
Disambiguating a class and a module in ruby
I am trying to move a ruby on rails app from ruby 2.3.4 to ruby 2.4.1, the app has a class called Warning however ruby 2.4 has added a core module called Warning. Is there an easy way to disambiguate the class ?

James
- 114
- 4
0
votes
2 answers
Ruby load does not see static methods in the class
I am experimenting with ruby (2.4.1p111) and with the load method and it does have some strange behavior:
I have two files:
mytest.rb:
class MyClass
def self.greet(param)
puts "Got called: #{param}"
end
greet 'Called locally'
load…

Pavel
- 88
- 6
0
votes
1 answer
How can I split Multipage pdf file into muliple pdf files in ruby
I would like to know is there any ruby gem or script to convert multipage pdf file into individual pdf files per pages in ruby. I tried with gems pdf-reader and prawn but not able to solve the problem. Help will be heartly appreciated. Thankyou.

codemilan
- 1,072
- 3
- 12
- 32
0
votes
1 answer
NameError: uninitialized constant Twilio::JWT
Getting an error while trying to generate access token for video
Using twilio-ruby (4.11.1), ruby 2.4.1, rails 5.1.0.
Code:
# Create an Access Token
token = Twilio::JWT::AccessToken.new(account_sid, api_key, api_secret, identity);
following…

devudilip
- 1,270
- 14
- 25
0
votes
4 answers
How can I tell if my string contains a substring from an array?
How can I tell if my string contains a substring from an array?
I thought include? was the key, but apparently not ...
arr = ["aa", "bb", "cc"]
str = "mystringcc"
str.include?(*arr)
ArgumentError: wrong number of arguments (given 3, expected 1)
In…
user7055375
0
votes
0 answers
Optimizing garbage collection with jsonapi-resources
I am currently using the jsonapi-resources gem in my Rails 5 application and I'm very happy with that. To optimize RAM consumption I wanna replace the .all call in my controller with the following:
def index
@cars = []
Car.find_each do…

Severin
- 8,508
- 14
- 68
- 117
0
votes
1 answer
How do I prevent array concatenation from changing the values of the arrays involved?
I want to create some constants that are array values, but seem to be having a problem when I try and concatenate them.
MALE_TOKENS = %w(m male)
#=> ["m", "male"]
FEMALE_TOKENS = %w(f w female)
#=> ["f", "w", "female"]
GENDER_TOKENS =…
user7055375
0
votes
1 answer
Custom exception in Ruby 2.3 and 2.4
I would like to rescue some code with a custom class in Ruby 2.3 and 2.4.
But unlike with the previous versions (such as 2.2 which was working great), I have some troubles. Here an example:
Given this class:
class CustomError <…

Cirus Polis
- 35
- 5
0
votes
1 answer
How do I switch the positions of words within a string?
I have an array of strings, each with at least one space in them. I would like to tkae the last part of the string and put it at the beginning, for every element in the array. So for example if I have this in my array
["RUBY RAILS"]
I would like…
user7055375
-1
votes
1 answer
Remove Field name from beginning of the error message in Rails?
How to remove the model name from the beginning of the error message. while writing custom message for a validation.
My validation is like:
validates :phone, presence: { message: "For security, please enter your mobile phone number…

vidur punj
- 5,019
- 4
- 46
- 65
-1
votes
2 answers
Ruby: iterate over two array of hashes and create array of arrays
I have two arrays of hashes
rtg with keys id, position_id, valid_from, valid_to
inv with keys id, position_id, date
Examples look like this:
rtg=[{:id=>7, :position_id=>3, :valid_from=>Tue, 05 Sep 2017 10:00:00 EEST +03:00, :valid_to=>Tue, 05 Sep…

matiss
- 747
- 15
- 36
-1
votes
3 answers
How do I access a module from an instance method in Ruby?
Suppose I have a module:
module M
def self.foo
...
end
def bar
...
end
end
Module M is included in a class.
class A
include M
end
I want to call foo from bar, which will eventually be called on an instance of A. What's the best…

Eli Rose
- 6,788
- 8
- 35
- 55