Questions tagged [ruby-2.2]

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

For issues relating to development in Ruby, version 2.2. It was released on December 2014. You can check the official docs here.

If your question applies to Ruby in general, use the tag .

119 questions
1
vote
1 answer

Ruby regex to match only single digits in a comma-delimited string

I am having input strings like: "1,7" "1,2,3, 8,10" "1, 4,5,7" I am trying to write a regex to match the above strings with following constraints are: it should match only single digits and that too in range of 1-7 the comma after a digit is…
Jignesh Gohel
  • 6,236
  • 6
  • 53
  • 89
1
vote
2 answers

What is the use of a variable in the class body?

I understand that when we define a class variable in ruby it's preceded with @@variableName but in this code class Hello @var2 @@var3=0 def foo1 return @var1 end def set_foo1(par1) @var1=par1 end end I…
SeasonalShot
  • 2,357
  • 3
  • 31
  • 49
1
vote
3 answers

RSpec raises NameErrors for code in subdirectory of /lib

I have a gem project with the following structure: foo-bar ├── lib │   └── foo │   ├── bar │   │   └── qux.rb │   └── bar.rb └── spec ├── spec_helper.rb └── unit ├── baz_spec.rb └── qux_spec.rb In lib/foo, bar.rb…
David Moles
  • 48,006
  • 27
  • 136
  • 235
1
vote
2 answers

Function overloading in Ruby

I have this piece of code in Ruby. class Superheros class<
SeasonalShot
  • 2,357
  • 3
  • 31
  • 49
1
vote
1 answer

Convert Active Record Object and String Attributes to JSON

I am trying to convert a Rails record into a fully Javascript-traversable JSON object. I can convert the basic record into JSON just fine, and I can convert each individual attribute into JSON just fine. However, I don't have a good way to convert…
steel
  • 11,883
  • 7
  • 72
  • 109
1
vote
2 answers

How to test SSH connection using Ruby

This is what I got so far. This works great, the problem being I can't input a password for the ssh login, I need to have shared ssh keys in order for this to work: def ssh_conn(user, host, &block) begin ping_output = [] …
skimisha
  • 143
  • 1
  • 10
1
vote
1 answer

Ruby JSON Multi-Word Strings Rendered Incorrectly in HTML

My multi-word strings aren't being interpreted correctly in the DOM. How can I ensure JSON integrity from server to HTML with multi-word strings? In the Rails controller, I store a JSON object in a variable. That object is correctly formatted when I…
steel
  • 11,883
  • 7
  • 72
  • 109
0
votes
1 answer

Error installing gem capybara-webkit getting the following error: Gem::Ext::BuildError: ERROR: Failed to build gem native extension

When installing the gemlock file I got the error of: I'm in experienced with Ruby, but what I'm attempting to do is simply run the application from github. It's a quite old program written in 2015…
0
votes
1 answer

weird undefined method [] but when debugging there is no errors

I've defined this method on ruby ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin14] and (Rails 4.2.5.2) def log_method_backtrace backtrace = [] (4..8).map do |i| # 4 because before is ... map, log_method_backtrace... b =…
Arnold Roa
  • 7,335
  • 5
  • 50
  • 69
0
votes
1 answer

How to ignore all *.php requests coming to RoR project in apache server?

Requests like unwanted .php files hitting my ROR production log Example: [2019-08-07T03:42:45.415176 #32608] INFO -- : Started GET "/java.php" for 213.74.248.28 at 2019-08-07 03:42:45 -0400 F, [2019-08-07T03:42:45.419677 #32608] FATAL -- : …
0
votes
1 answer

rbenv and nokogiri errors on MacOSX

I have tried everything google has thrown at me to get my rails application running with nokogiri. I am running my app using ruby v2.2.7 and my ruby version is managed via rbenv. I have followed every step here…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
0 answers

Performance Optimization: SQL query and looping over the grouped object (hash)

My Association is like this field has_many field_values field_value belongs_to field I am querying field_values table to get field_values grouped by field_id like this: def field_values FieldValue.where(field_id: @field_ids) …
0
votes
0 answers

Cocoon link_to_add_association : ArgumentError: wrong number of arguments (2 for 1)

I am integrating Cocoon to add multiple attachment with my property object. But when I am creating new property record, I am getting ArgumentError: wrong number of arguments (2 for 1) error = form_for @property, remote: true, authenticity_token:…
Vik
  • 5,931
  • 3
  • 31
  • 38
0
votes
0 answers

Windows-friendly linebreaks for ruby output to file

I've got a test result log to parse that is basically just a bunch of key=value pairs on sequential lines separated by a // at the end. Everything seems great except the output file. In normal Notepad, it looks fine. In Notepad++, it has a bunch of…
kayleeFrye_onDeck
  • 6,648
  • 5
  • 69
  • 80
0
votes
0 answers

Rails s command gives Segmentation fault

If i run rails s i am getting this error /Users/test/.rvm/gems/ruby-2.2.2/gems/pg-0.19.0/lib/pg_ext.bundle: [BUG] Segmentation fault at 0x00000000000440 ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin16] Abort trap: 6 Versions ruby ruby…
amtest
  • 690
  • 1
  • 6
  • 26