Category "ruby"

Rails App Breaks with 404 Error when Last.fm API Call Returns Nothing

I wonder if anyone can help, and if the issue is specific to Last.fm (perhaps not the greatest of APIs). I've built an album search feature into my app that tak

I am trying to create a post in instagram clone in ruby and rails but it throws an error "no implicit conversion of Integer into string"

This is the Post Model class Post < ApplicationRecord mount_uploader :image, ImageUploader scope :active, -> { where active: true } end This is

Set a new value after using regex

I have a string that is equal to stringnum. stringnum = "0007001369920090687073" I need to use regex to grab the first 9 digits after the first 3 zeros. I am u

Remote url failed to load in asciidoctor-epub3

I'm unable to generate/view the image from a remote URL while generating the Mobi. Whereas it works for asciidoctor when converting adoc to HTML Code look some

Whats missing on my Ruby 'Inverse Of' relationship

I know this topic has been addressed, but I have been at this for 2 days and I'm just stuck. I know inverse of does not create a new query, so should I use anot

Ruby : Cannot load such file --ruby2d (LoadError)

I'm new to Ruby,Writing some code to make a game,so using ruby2d library. Got an error while writing some basic code. Help me out Folks. require 'ruby2d' set ba

How to refactor round method with 3 digits

I would like to round float numbers like this : 125.212 = 125.250 125.249 = 125.250 125.268 = 125.250 125.280 = 125.275 125.999 = 126.000 I have do a method, h

Obtain all commits in all branches Using Ruby Rugged

Using the Rugged gem, I want to obtain all commits in all branches, similar to this git command line: $ git log --all Walker requires a branch, so the followin

Library functions in Inspec Test

Team -- I have a ruby library helper in which I have defined multiple functions/methods. How do I reference those in Chef Inspec tests? def interface_name # s

Writing structured facts

I've wrote some ruby code which will run on a linux server and return details about the server as a fact. It does this by connecting to amazon and retrieving so

Object and Pointers Graph Representation in Ruby

I am studying how to represent a graph in memory with Objects and Pointers in ruby and cannot find a representation of this anywhere. Can anyone point me in the

Why am I getting a nil value from a Ruby object's member, when it is not nil? [closed]

I want to get the value of a field (ScenarioID) in a Ruby ActivityChart object (chart). Displaying the whole chart shows the value I want: 16

Attempting to register a user on my devise app causes undefined method `user_url' for #<Devise::RegistrationsController:0x00000000020ee0>

I am still getting this error when I'm trying to register new user, but I can log in to created user after refreshing page. Here is code which I'm getting on th

How to wait for all Concurrent::Promise in an array to finish/resolve

@some_instance_var = Concurrent::Hash.new (0...some.length).each do |idx| fetch_requests[idx] = Concurrent::Promise.execute do response = HTTP.get(EXTD

HAVE_MENU unset when compiling ncurses for Ruby curses extension on Mac?

I'm trying to use Ruby's curses library wrapper, but getting a uninitialized constant Curses::Item (NameError) error when trying to make a menu or items, despit

longest subsequence: missing last element

Hi guys I'm working on the longest subsequence algorithm, the idea is to find the subsequence of numbers from an array. I'm using Ruby, so far I'm missing the l

Ruby NoMethodError: undefined method

I am using rack-reducer with rails. I am getting the error: #<NoMethodError: undefined method 'order_from_user_input' for #<DataPoint::ActiveRecord_Relati

How to search nested hash of arrays and arrays of hash and return multiple matching objects from the parent node?

Say I have the below ruby hash nested hash_or_array = [{ "book1" => "buyer1", "book2" => { "book21" => "buyer21", "book22" => ["buyer23", "b

Generating files in Docker vs. Docker Compose

I am learning Docker and have a little confusion that I would greatly appreciate some advice on. When creating a new rails application. Following the guidelines

The sum of all numbers less than 1000, multiples of 3 or 5

If we list all natural numbers less than 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all numbers le