• Mongoid querys memory limit 2018-10-23

    I have around 1 million records in my database. When I do: MyModel.distinct(:my_field) getting this error - failed with error 17217: "exception: distinct too big, 16mb cap" Tried to do it via aggregation - getting the same error. group = {"

    Tags: ruby, mongodb, mongoid
  • Minitest mocking Sinatra app 2018-10-15

    I have Sinatra app inherited from Sinatra::Base class. In this app I have one helper method which I use in before filter. How to mock such method in tests using minitest mock library? before do unless valid_signature? halt 401 end end --------------S

    Tags: ruby, mocking, sinatra, minitest
  • MiniMagick Wrong Command when Covert PDF to PNG? 2018-09-07

    I using MiniMagick gems. And I am currently doing this: do |convert| convert << input convert << '-verbose' convert << '-density' << 720 convert << '-quality' << 100 convert << '-colo

    Tags: ruby, graphicsmagick, minimagick
  • Cannot install Ruby-Mapnik 2018-09-06

    I'm trying to install Ruby-Mapnik with no luck. Before this, I installed Mapnik version 3.0.0-pre with success. $ mapnik-config -v 3.0.0-pre So. First I tried to install the gem, but got it wrong: $ sudo gem install ruby_mapnik Fetching: rice-1.7.0.g

    Tags: ruby, gem, installation, mapnik
  • Facebook Grouping related posts reading from Ruby program using Koala 2018-09-02

    I am implementing a ruby program to automatically read birthday posts from facebook timeline. I am using the Koala library. A short version of my code can be found here - In the response feed instea

    Tags: ruby, facebook graph api, koala
  • Encountering probles install cocoapods (Xcode) 2018-08-21

    I'm having issues installing cocoa pods to my college's computer. I talked to the technical director for the CS department, who used admin privileges to SSH into my computer and install cocoa pods. However, when I try to call pod install onto the dir

    Tags: ruby, xcode, cocoapods
  • Prevent conditional checking on Hash to create Key 2018-07-26

    Whenever I run a conditional checking on Hash to see if a key doesn't have any value, it creates that key x = {|h,k| h[k] = []} puts x >>>>{} if x[0] == [] puts "Ok" end >>>>Ok puts x >>>> {0=>[]}

    Tags: ruby
  • Two files are found in WATIR-Classic 3.0.0 but not in WATIR-Classic 3.7.0 2018-07-01

    I can find two files named 'testcase.rb' and 'assertions.rb' in WATIR-CLASSIC 3.0.0, but those two files are not found in WATIR-CLASSIC 3.7.0. What is the reason for this? Or is it found in some other folder? --------------Solutions------------- In w

    Tags: ruby, watir, watir classic
  • Ruby: How to generate direct access keys to nested hash which contains hash & arrays as values? 2018-06-04

    I was happened to compare 2 xml files where one is input xml and the other one is output xml. I am converting both the xml into hash. My Idea is to get all the keys from input hash(input xml converted to hash) like above and search each key in the bo

    Tags: ruby
  • Ruby interpreted variables is_a? 2018-05-17

    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-09

    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-30

    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-29

    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-08

    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-23

    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-05

    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-05

    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-04

    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-18

    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-12

    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

Copyright (C), All Rights Reserved.

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