How can I convert an IO object to a string in Ruby?
I'm working with an IO object (some STDOUT output text), and I'm trying to convert it to a string so that I can do some text processing. I would like to do something like this:my_io_object =...
View ArticleCan we method chain on lists?
I come from Ruby and you can method chain very easily. Let's look at an example. If I want to select all even nums from a list and add 5 to it. I would do something like this in Ruby.nums =...
View ArticleHeroku Rails App Returning "Not Found" When trying to GET, POST etc to API...
I tried updating the rack cors for rails but every time I try to get data from the API externally from localhost. I get a "Not Found" payload/error.Any suggestions?Rails Version: 7.1.3Ruby Version:...
View ArticleHow do I map an array of hashes?
I have an array of hashes:arr = [ {:a => 1, :b => 2}, {:a => 3, :b => 4} ]What I want to achieve is:arr.map{|x| x[:a]}.reduce(:+)but I think it's a bit ugly, or at least not that elegant...
View Articleuninitialized constant Google::Cloud::Vision::ImageAnnotator
Running this examplehttps://cloud.google.com/vision/docs/face-tutorial?hl=zh-twby rails on 'google-cloud-vision', '~> 0.31.0'got the error uninitialized constant...
View ArticleHow can I see ICMP error messages in response to UDP messages in Ruby?
I am trying to build a kind of traceroute in Ruby. The principle is that I send a UDP message with a TTL of 1 to the desired destination and get an ICMP error message back from the first hop. Since I...
View ArticleSSL_connect returned=1 errno=0 state=SSLv3 read server certificate B:...
I am using Authlogic-Connect for third party logins. After running appropriate migrations, Twitter/Google/yahoo logins seem to work fine but the facebook login throws exception:SSL_connect returned=1...
View ArticleRuby dynamically determine class and calling methods
I have a factory module which returns class, like this# frozen_string_literal: truemodule Factory module Subscriptions module SubscriptionSelector class << self def...
View ArticleThe sum of two network masks in ruby
Amazon now owns 3.0.0.0/8Apparently bought in two chunks: 3.0.0.0/9 and 3.128.0.0/9.How do I write program in Ruby to add 3.0.0.0/9 and 3.128.0.0/9 and get result - 3.0.0.0/8?I can convert mask to cidr...
View ArticleRails 7 - does not disable Turbo on form_for [closed]
In my Rails 7 and Ruby 3.2.1 app I've got below show.slim:= turbo_frame_tag 'show-user' do = form_for(@user, html: { 'data-turbo': "false"}, url: user_routes.user_path(@user)) do |f| = render...
View ArticleChecking if a string is valid json before trying to parse it?
In Ruby, is there a way to check if a string is valid json before trying to parse it?For example getting some information from some other urls, sometimes it returns json, sometimes it could return a...
View ArticleFirefox Iframe issue on Watir: Watir's iframe Handling issue with few...
Watir Firefox Issue with iframe HandlingI'm experiencing an issue with Watir's iframe handling in Firefox. The issue does not occur in Chrome.Environment:Watir Version: 7.3Selenium Version: 4.2Browser...
View Articleundefined method `zone` for Time:Class after requiring...
I'm on Ruby 2.2.1 and have active_support 4.2 installed so I want to use Time.zone.parse('2007-02-10 15:30:45')as described here: http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.htmlBut...
View ArticleSassC::SyntaxError in ActiveAdmin::Devise::Sessions#new
I am using arctic_admin gem . Following https://github.com/cprodhomme/arctic_adminI have added in the gem file gem 'arctic_admin'in /app/assets/javascripts/active_admin.js file//= require...
View ArticleIn Rails, can I order a query by a delegate method?
I'm having difficulty ordering a query by a delegate method. I've been tasked with helping upgrade a fairly large Rails 3 application to Rails 4. I've come across this query in an index action.#...
View ArticleFixing DEPRECATION WARNING: Calling ActiveRecord::Base.clear_active_connections
I'm working on a Ruby Sinatra app with Active Record and it gets this error message printed in the console with every HTTP call.I couldn't find anywhere more information about this deprecation or how...
View ArticleUnable to download the file via Google Drive API using Ruby
Is it possible now to use Google Drive API without oauth authentication?Basically what I need is download the file from my google drive. I created a service account and shared the file to it, then used...
View ArticleRuby: replacement part include $1 $2 $3 and saved in a variable, but...
(a) the codes I wrote.$str = '909090 aa bb cc dd ee ff 00 12345678 aa bb 12345678 aa bb cc dd ee ff 00 11 22 33 123456 FE 89'puts $str$str.gsub!(/\s+/, '')search_1 = 'aa bb cc dd ee ff 00 (\S{8} aa bb...
View Articleruby** reverse array without using reverse method
This is my array and custom method to reverse an array output without using the reverse method. not sure where it broke, tried running it in console, no dice.numbers = [1, 2, 3, 4, 5, 6]def...
View ArticleWhat is the difference between Raising Exceptions vs Throwing Exceptions in...
Ruby has two different exceptions mechanisms: Throw/Catch and Raise/Rescue.Why do we have two?When should you use one and not the other?
View Article