Questions tagged [ruby-2.0]

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

ruby-2.0
Filter by
Sorted by
Tagged with
3 votes
1 answer
2k views

Unicorn and Gemfile are using different ruby versions when trying to run unicorn and Nginx on Digital Ocean

I am trying to run my Rails app through Nginx and Unicorn and when I try to run service unicorn start it tells me I fail with master failed to start, check stderr log for details. My Gemfile specifies ...
jjasonn's user avatar
  • 41
0 votes
0 answers
211 views

Email is not going from rails app when using siteground mail id

I am using Ruby 2 and Rails 4. I am trying to sending a mail from my application. When I use gmail account it works nicely But when I use Site Ground account it does not work. I have an email account ...
Priyank Dey's user avatar
  • 1,114
1 vote
1 answer
348 views

Scrollspy not working (BS 3 and Rails 4)

I'm building a long page and want the tabs of the navbar to become active as someone is scrolling on the page. Since I'm using Bootstrap 3, I thought scrollspy would work. However, I can't get it to ...
DJF's user avatar
  • 47
0 votes
0 answers
158 views

YAML parsing error in Travis CI, but not locally

I'm using Travis CI for a gem I'm developing and ran into a strange error (links are at the end of the question). The gem is storing some information serialized with YAML which isn't built manually, ...
stex's user avatar
  • 861
0 votes
1 answer
53 views

Ruby giving Error while assigning

I am new to ruby I was just trying this in "irb" string = "www.google.com" a,e=string.count "a", string.count "e" It's giving an error SyntaxError: (irb):50: syntax error, unexpected tSTRING_BEG, ...
jeet's user avatar
  • 27
1 vote
2 answers
556 views

how to sort a hash with both keys and values

consider a hash my_hash = {"drsn"=>["on", "tw", "th"], "mhsh"=>["tw", "th", "fo"], "achu"=>["th", "fo", "fi"]} i can sort the hash by Hash[my_hash.sort] which leads to a sorted hash like ...
Aparichith's user avatar
  • 1,507
1 vote
2 answers
241 views

Understanding ruby modules

I am new to Ruby, using eclipse, DLTK ruby plugin and Ruby 2.0. I created an Ruby module file called AModule.rb which has the code: module AModule aConstant = 7 end This is called from a test ruby ...
sid smith's user avatar
  • 533
1 vote
1 answer
341 views

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? ...
Grant Birchmeier's user avatar
0 votes
2 answers
93 views

How to omit last character from the each word in ruby?

So I have this paragraph. Hello how are you doing? how are wew And I would like to omit all the last "w" character from this paragraph? How do I do this with ruby. I have tried puts(#{string})....
Amatya's user avatar
  • 13
0 votes
4 answers
118 views

How to iterate through an array and pass each element onto a method?

Suppose I have two arrays with numbers inside. I want to iterate through both arrays and pass each element to a method that accepts 2 parameters. x = [2,3,9,1] y = [1,9,2,1] def add (x,y) x+y end ...
Beast_Code's user avatar
  • 3,137
0 votes
1 answer
67 views

`%': can't convert Spreadsheet::Column into Integer (TypeError)

I receive the following error while using Ruby 2.0 with the Spreadsheet Gem: %': can't convert Spreadsheet::Column into Integer (TypeError) I am using the spreadsheet guide for the spreadsheet gem....
Beast_Code's user avatar
  • 3,137
1 vote
1 answer
750 views

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 ...
Micka's user avatar
  • 1,757
3 votes
2 answers
74 views

Why does "each"-ing a range only work with incrementing ranges? [duplicate]

This makes absolutely no sense: irb(main):001:0> (1..10).each do |x| irb(main):002:1* puts x irb(main):003:1> end 1 2 3 4 5 6 7 8 9 10 => 1..10 whereas: irb(main):004:0> (10..1).each ...
Blake's user avatar
  • 715
0 votes
1 answer
288 views

Run external processes in non-blocking mode

I want to perform some actions in parallel periodically and once they're all done, show the results to the user on a page. It'll happen approximately 1 time per 5 mins, it depends on the users' ...
Incerteza's user avatar
  • 33.6k
7 votes
1 answer
286 views

Big Decimal Stored as 60.00, Returns as 0.0?

I am customizing a Spree 2.3 application in Rails 4. When I save a price.amount, it appears to save correctly in the database, but when I retrieve it, it is wrapped in the BigDecimal class and returns ...
steel's user avatar
  • 12.2k
0 votes
0 answers
61 views

Cannot load such file `Tokyo-Rufus` even though Gem is included

I am trying to create a simple Sinatra app. I wanted to add user authentication using Sinatra-Authentication. I have been using their github site and this blog. I used the 2nd example using Tokyo-...
dev's user avatar
  • 1,487
0 votes
1 answer
336 views

Ruby string prepend '\' character

why ruby is prepends '\' character while I am trying to run below code. It is happening with only '#$' It is happening with all ruby version. puts '#$' => '\#$' or '#$' => '\#$' or '...
RKP's user avatar
  • 174
3 votes
1 answer
7k views

Why am I getting '`parse': (<unknown>): mapping values are not allowed in this context' in YAML file in Ruby

I am getting the above error when trying to open my Yaml file in Ruby. I have checked the YAML in this validator and it has passed http://yamllint.com/. I'm not sure what could be wrong with my YAML ...
Brent Moses's user avatar
0 votes
1 answer
275 views

simple logic finding closest upcoming day of the week using Ruby

I have an array days where the days of the week are numbers. 0 = sunday, 1 = monday, etc. days = [0, 1, 3, 4] # this is just an example, the list is dynamic, it could be any combination of days (non ...
ere's user avatar
  • 1,749
1 vote
1 answer
927 views

Building option list with haml

I'm trying to create a select control with options using HAML in Sinatra. There should be an option for each value in my @ages array. I have verified that @ages is actually in the view by printing it ...
Antarr Byrd's user avatar
  • 25.6k
-1 votes
1 answer
1k views

issue in upload a csv file to s3

in application path public/users/user_list.csv is present. I need to upload this CSV file to s3 . Now, in S3 it is storing as text file, not as CSV. I am Using paperclip. file_to_s3 = File.open("...
jissy's user avatar
  • 463
7 votes
2 answers
8k views

Rails 4 server fails, Ruby 2.0 segmentation fault, Abort trap 6

I just started going through railstutorial.org and getting my development environment setup. When I got to the section 1.2.5 to run rails server for the fist_app, I type the command and the following ...
apflower's user avatar
0 votes
0 answers
150 views

"nil can't be coerced into Fixnum" model error in rails

I am working on Q&A app in ruby on rails. I am getting error as "nil can't be coerced into Fixnum" This application is working fine on heroku (Please see bottom for demo project link.) here is my ...
niraj007m's user avatar
2 votes
1 answer
2k views

ActionController::TestResponse does not respond to method has_selector?

I'm following the older version (for Rails 3) of Michael Hartl's Rails screencasts. However, I'm using Ruby 2 with Rails 4 (rspec-rails 3.0.1), interpolating between the lessons and practice via ...
0xC0FFEE's user avatar
3 votes
2 answers
4k views

Specify Character Encoding for Net::HTTP

When I make this HTTP request: Net::HTTP.get_response('www.telize.com',"/geoip/190.88.39.27").body => "{\"timezone\":\"America\\/Curacao\",\"isp\":\"United Telecommunication Services (UTS)\",\"...
Tom Rossi's user avatar
  • 11.8k
0 votes
1 answer
477 views

rest-open-uri on heroku with ruby 2.0

Since the default encoding is now utf-8 for Ruby 2.0, the rest-open-uri gem throws the following error on heroku: /app/vendor/bundle/ruby/2.0.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `...
user3731114's user avatar
0 votes
2 answers
105 views

Undefined method error for << in ruby

I'm learning Ruby with The Fundamentals of Ruby course, by José Mota, and while following the course I got these errors, I'm not sure what happened. The code is exactly the same as the video in the ...
monk's user avatar
  • 4,787
0 votes
1 answer
250 views

Why is Digest::SHA1 preventing proper annotation of a model?

I am using annotate in my app and all models are successfully annotated except for user.rb, which shows the following error when I annotate: Unable to annotate user.rb: wrong number of arguments (0 ...
topher's user avatar
  • 301
30 votes
2 answers
35k views

Ruby 2.0.0 String#Match ArgumentError: invalid byte sequence in UTF-8

I see this a lot and haven't figured out a graceful solution. If user input contains invalid byte sequences, I need to be able to have it not raise an exception. For example: # @raw_response comes ...
Tom Rossi's user avatar
  • 11.8k
0 votes
1 answer
853 views

Can't install Bluecloth 2.2.0 gem in windows 7

When Running bundle install i am getting below error. Note: I also tried gem install bluecloth --platform=ruby but same problem. Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem ...
A H K's user avatar
  • 1,758
10 votes
2 answers
421 views

Strings that compare equal don't find same objects in Hash

I have two strings that appear equal: context = "Marriott International World’s Most ADMIRED Lodging Company by FORTUNE for 14th yr. via @FortuneMagazine http://cnnmon.ie/1kcFZSQ" slice_str = context....
Rich Sutton's user avatar
  • 10.4k
0 votes
0 answers
1k views

Installing gem "binding_of_caller" creates error and will not install

I've attempted to bundle the following gem: gem 'binding_of_caller', '~> 0.7.2' This results in the following error message. I've looked around to see how to fix it but can't find anything that ...
Robbo's user avatar
  • 1,302
3 votes
1 answer
3k views

Rails 4.1 AWS Beanstalk cannot find secret key base

I am trying to upload my rails project on AWS Beanstalk. I've already run eb init, eb start and configured the database settings to point to RDS. After I pushed using git aws.push and waited for AWS ...
Need A Hand's user avatar
4 votes
1 answer
2k views

How to pass array to class option of rails generator?

I'm creating the following ruby class generator: class Template < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) argument :name, type: 'string', required: true ...
gotqn's user avatar
  • 43.2k
6 votes
2 answers
2k views

How to get the name of the calling alias method?

I am having method called link_to_admin then I have aliased another method called simple_link_to def link_to_admin(name,url,options={}) # My stuff here link_to(name,url,options) end ...
Jenorish's user avatar
  • 1,704
0 votes
1 answer
320 views

Ruby: Process.wait is throwing `Invalid Argument` exception on long operations of +300 seconds

I have the following ruby script which kicks off 12 processes which smoke test my application. Some of these can be long running of up to 8 minutes. pids = [] pids = uris.map do |uri| ...
Neil's user avatar
  • 5,229
0 votes
1 answer
384 views

Ruby: running external processes in parallel and keeping track of exit codes

I have a smoke test that I run against my servers before making them live. At the moment it runs in serial form and takes around 60s per server. I can run these in parallel and I've done it with ...
Neil's user avatar
  • 5,229
0 votes
2 answers
49 views

Converting an array into a hash with format { value => position_in_array }

I have an array of numbers in string format, and I want to convert them into a hash where the keys are the numbers and the values are the positions of those numbers in the array. So for example: ["1",...
Ege Ersoz's user avatar
  • 6,521
0 votes
1 answer
2k views

Local gem class is not found in Rails application

I have written a generator which creates the following ruby file and folder: app/tests/test.rb in the test.rb file I have a Test class which looks like this: class Test < MyCustomModule::...
gotqn's user avatar
  • 43.2k
0 votes
1 answer
193 views

New form failing in Rails 4 with undefined method for one of the form fields

Rails 4.1 Ruby 2.0 Windows 8.1 When I try to create a new hobbyist, I get the following error: undefined method `organization' for #<Hobbyist:0x000000070d0ac8> With the following additional ...
EastsideDev's user avatar
  • 6,429
1 vote
1 answer
601 views

ElementNotVisibleError when clicking on imagemap-area using Watir Webdriver

I'm using Watir Webdriver and I am trying to click on an area on a HTML imagemap. The single areas are found (exists? == true) but an error appears telling me that the element is not visible: > ...
Hedge's user avatar
  • 16.5k
1 vote
1 answer
541 views

Always call function only once when executing a script

i've got a class like this one below. I introduced the loghelper-function to create the necessary logging-elements. All 3 functions (start, function1, function2) can be run via console with rails r "...
Hedge's user avatar
  • 16.5k
1 vote
1 answer
292 views

Stack level too deep when compiling javascript files on ElasticBeanstalk Ruby2.0 on Rails3

I'm trying to migrate our Rails3 app from old ElasticBeanstalk environment running Ruby 1.9.3 to new one running Ruby 2.0. Everything seems to work fine except "stack level too deep" error on assets ...
Johnny Le's user avatar
0 votes
1 answer
40 views

Pass form values across views

In my first view I want to select a number in my form and have my second view include a check within a checkbox for that selected number. How can I pass values from view1 to view2?
Simon  Noumedem's user avatar
-1 votes
1 answer
57 views

Ruby : get more then one decimal zero?

My code: def cube_root(x) a = x**(1/3.0) p = a.ceil puts p end gets.chomp.to_i.times do q = gets.chomp.to_i cube_root(q) end input 2 8 1000 output 2.0 10.0 Expected output 2....
bindi bhatt's user avatar
0 votes
0 answers
40 views

Delayed job Failing with noe reason

I am running a quite simple rails app, that sends emails with ActionMailer whenever a user completes a form. The problem I have is that DelayedJob is failing without any errors. I run delayed job ...
Trt Trt's user avatar
  • 5,468
0 votes
1 answer
22 views

Ruby - Unable to count the array values?

I have a program : Question : Input a number of integer of 2 digit only , and in the out-put it should show the all input values BUT loop should stop on 42 : example input 1 2 87 42 99 output 1 ...
bindi bhatt's user avatar
3 votes
1 answer
3k views

Should I use Ruby 1.9x or 2.0x? [closed]

I used to write some Python, and I know there are a lot of difference between Python 2.x and Python 3.x Current now, I hope to use some Ruby to write a website (Maybe use Rails), but I am afraid that ...
zproject89's user avatar
1 vote
1 answer
406 views

Rails: sleep until there is data to respond with (streaming + multithreading)

I am building a Rails/Javascript application which is supposed to support real-time notifications. JavaScript is: var chat; $(document).ready(function(){ chat = $('#chat'); chat.append('mmm')...
Paul's user avatar
  • 26.2k
0 votes
1 answer
58 views

Could not find javascript runtime environment,ruby 2.0

I am trying to set up ruby 2.0 with rails 4 on my local machine. So after installing when i tried to generate scaffold it says "Could not find javascript runtime environment". To fix this issue I ...
shettarvinay's user avatar

1 2
3
4 5
10