• Ruby interpreted variables is_a? 2018-05-13

    I am looking to check a variabe for its type based on the value held in another variable but am struggling with it. I'm completely new to ruby but can anyone tell me how to have the value of a variable interpreted in the expression? My current code l

    Tags: ruby, variable types
  • Dynamic parameters for method 2018-05-07

    I have some normal set methods for a class which i want to call from a dynamic context. But i am having trouble with building up the method call from variables. Example code setters def set_name(value) @name = value end def set_size(value) @size = va

    Tags: ruby, metaprogramming, dynamic programming
  • Building a JSON string from act_as_tree tree 2018-04-28

    I am new in learning Ruby. In a program, I have used acts_as_tree to build an organization tree from a hierarchical table. Now, I wish to build a JSON string from the data contained in tree nodes. In the JSON output, each parent node will have an att

    Tags: ruby
  • drying a block using proc in Ruby 2.2 2018-04-26

    I have a piece of code that I would like to DRY up: def start queue1.pop_all do |record| # some non-trivial logic end queue2.subscribe_one do |record| # the same set of non-trivial logic end end One way I have come up is to create a private method th

    Tags: ruby
  • Else part is not working in Rails ajax form 2018-03-05

    I have a Rails ajax form to submit.When user will give the correct data it will search the database and do the operation accordingly.If user is giving the Wrong data it should display user to alert message.But it is not happening like that. I am expl

    Tags: ruby, ajax, ruby on rails 3.2
  • Already initialized constant APP PATH rails 2018-02-19

    I got this error just after installing devise 3.4.0 gem in my application. When I input rails s in terminal, I get the error below.. [[email protected] register]$ rails s => Booting WEBrick => Rails 4.2.1 application starting in development on http:

    Tags: ruby, ruby on rails 4, devise
  • Ruby issues while running sensu checks 2018-02-02

    I am getting the below error while trying to run the sensu checks my ruby version is ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux-gnu] /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- sensu

    Tags: ruby, sensu
  • ruby padding an array 2017-12-03

    I'm getting the following error when I run my code from my rspec file: pad pads element to the end of an array Failure/Error: expect(pad(array,array.length + pad_size, 'apple')).to eq(, 'apple')) expected: ["apple", "

    Tags: ruby, padding
  • Uploading a file using the Ruby SDK to Amazon S3 2017-12-01

    I am trying to upload a file. A simple hello.txt. I was following the docs, and I am unable to upload it to my bucket. # START AWS CLIENT s3 = bucket = s3.bucket(BUCKET_NAME) begin s3.buckets[BUCKET_NAME].objects[KEY].write(:fil

    Tags: ruby, amazon web services
  • Unable to open Locknote on Windows 7 using Ruby 2.0 2017-11-17

    I ran this code, and all it did was take me to the folder of the executable. I had to click on the application exectable to open it. Isn't this supposed to open automatically? require 'Win32API' def user32(name, param_types, return_value)

    Tags: ruby, winapi
  • How are hashes with identical keys used to relate menu items with order item prices in the following tutorial? 2017-11-10

    I am working on the problem of 'Orders and costs' Problem Statement is: A restaurant has incoming orders for which you need to compute the costs based on the menu. You might g

    Tags: ruby, hash
  • Ruby Curses getch in cbreak mode doesn't handle Ctrl+C automatically on Windows 2017-08-30

    In cbreak mode terminal should handle some control characters automatically, but it does not: require 'curses' Curses.init_screen() Curses.cbreak() loop { Curses.getch() } On GNU/Linux Ctrl+C interrupts the program. On Windows Ctrl+C just prints ^C a

    Tags: ruby, windows, curses
  • Trying to install ruby on rails on windows for three days now 2017-08-04

    This is how it goes: 1) I go to everything is good here 2) I download the installer and devkit everything is good here 3) I install both in that order then run command to link to devkit to ruby. everything is good here 4) I create a

    Tags: ruby, sqlite3, ruby on rails 3
  • Improving algorithm execution time and prime numbers 2017-08-02

    I am trying to find the largest prime value of a big number, but it takes far too long. For example, to find the largest prime of 999999999, it takes about 55 seconds. How can I improve this? require 'prime' def highestprime num i = 1 counter = 0 cou

    Tags: ruby, algorithm, primes
  • Modularizing Test Script in Ruby(MiniTest Framework ) 2017-06-04

    Working script File name : test_data.rb" class TotalSample < MiniTest::Test @name = 'Arg1' @period = 'Arg2' @usage = 'Arg3' @siteName = test1_activedata = @siteName.getActiveData(@period) test1_sample = test1_activedata["sampl

    Tags: ruby, junit, minitest
  • Ruby: variable acting as nul when set to integer 2016-09-28

    After a good 10 minutes of trying to come up with a more informative title, I ran out of ideas. I have 2 prolems. The first is that whenever I try to input a position for pos_in, it registers as nul when run through the case statement that determines

    Tags: ruby, variables
  • RSpec thinks created file is empty 2016-09-21

    I've created a class that creates a new text file. When I try to compare it with an existing file it seems that RSpec thinks the created file is empty. expect(open @expected).to eq(open @result) The result: (compared using ==) Diff: @@ -1,2 +1,2 @@ -

    Tags: ruby, rspec
  • Travis CI is faling to run tests with **/*_test.rb pattern 2016-09-09

    My micro Ruby project tests works on my machine, on private VM, but fails on Travis CI bulid Project uses both rspec (+rspec-given) and minitest Full trace here: $ bundle exec rake MiniTest::U

  • Chris Pine Ch. 6 Deaf Grandma 2016-08-16

    I am following Chris Pine tutorial. In one of the exercises I have to write to "Grandma" BYE three times in a row to shut the program. But my program can shut even if I don't type "bye" three times in a row. Why? puts "Do you need

    Tags: ruby
  • if page has selector - Capybara 2016-08-02

    Im trying to implement a simple piece of logic that says if element exists on page do something The issue I am facing is that if the element doesnt exist then the find method provided returns an exception and will fail my test. (Capybara::ElementNotF

    Tags: ruby, rspec, capybara

Copyright (C), All Rights Reserved.

processed in 0.233 (s). 7 q(s)