why do non numbers get converted to integers in ruby? [duplicate]
I do this:puts "What's your number? "x = gets.to_iputs x.classIf the user types in 3, that string (input) is converted to an integer. But if I type in "Charly", that too gets converted to an...
View Articlebundle exec jekyll serve not working locally
I am following this link to setup my personal website on Github. The website has been deployed successfully and I can visit it now.My ruby version is 3.3.0 and my gem version is 3.5.4. I have also...
View ArticleHow do I assign a monetary value to each array within Ruby?
I'm creating a Ruby program that ask how many computers you want and its has arrays for computers, monitors, and a free item. I want to add a cost to each of the arrays. If I could add a value to each...
View ArticleIs there a way to use Rspec let! with a scope so it can be used across...
I'm trying to figure out a good way to handle setting rspec memoized variables that will be cleaned up after a set of tests, but not after an individual test.I'd like it to achieve something similar to...
View ArticleWhy do I get an error installing the JSON gem in Ubuntu?
Using Ubuntu, when I run "bundle install" to set up my Rails environment, it throws an error during the JSON gem installation:Installing json (1.7.3) with native extensions...
View ArticleHow can I use locales in my gem from another gem?
I have a gem that uses another gem. That other gem has translations (I18n). When localization is applied in my library, instead of text I see a value with a missing translation:Translation missing:...
View ArticleHow do you handle bad requests with RSpec tests in Rails?
In my test database, I have reviews that i am making API calls to in my API-only Rails 5 app. So far i have written tests for my index and show actions for the ReviewsController. How do i handle...
View ArticleHow do I handle associations in Ruby on Rails when the JOINS involve more...
I'm working on a Ruby on Rails server (v6.0.1) and I'm looking for cleaner ActiveRecord joins when the join involves three tables. Here's a barebones reproduction of five models under consideration to...
View ArticleHow to compile & run Ruby c (/c++) extension with OpenMP (undefined symbol...
I'm trying to do a simple parfor loop in a Ruby c/c++extension using openmp#pragma omp parallel forfor (int j = 0; j < 100; j++) {}extconf.rb:require 'mkmf'extension_name = 'stridx'$CFLAGS <<...
View ArticleWhen to use dump vs. generate vs. to_json and load vs. parse in Ruby's JSON lib?
david4dev's answer to this question claims that there are three equivalent ways to convert an object to a JSON string using the json library:JSON.dump(object)JSON.generate(object)object.to_jsonand two...
View ArticleInterpolation in local variable name Ruby
I've gotbanana_charge_1_bananas_sold = 0banana_charge_2_bananas_sold = 0banana_charge_3_bananas_sold = 0banana_charge_4_bananas_sold = 0banana_charge_5_bananas_sold = 0andsale_ticket.banana_chargewhich...
View ArticleHow to update Ruby with Homebrew?
I want to know how to update to the latest stable version of Ruby with Homebrew. I am not interested in using RVM. Thanks.
View ArticleHow to get a refresh token when using the Google Calendar API Ruby Library?
I'm a newbie trying to implement the Google Calendar API into a web-based app and after following the instructions that they provide to the t, fetching information only works for about 20 minutes...
View Articlewhat order do cucumber tests get run
I know cucumber runs each test in a feature file from top down, but my question is, in what order do feature files get run? It doesn't seem to be alphabetically, or in any structure order.
View ArticleHow to change axes for component from ruby api
I have created an Dynamic Component which depend of its options. I need to change axes for component from ruby api. But I can't understand how to do it.I tried this way, but it doesn't work out. Any...
View ArticleTrouble Implementing add_3d_text in SketchUp Ruby API for Dynamic Text...
What are the details of your problem?I'm working on a Ruby script for SketchUp to automate the process of adding text annotations within my model. I need to count instances of specific components...
View ArticleHow to test if user input in a number? [duplicate]
I do this:puts "What's your number? "x = gets.to_iputs x.classIf the user types in 3, that string (input) is converted to an integer. But if I type in "Charly", that too gets converted to an...
View ArticleGenerate array based on two others
I have two arrays:[["106373", "106374", "106375", "106376"], ["106377", "106378", "220183", "220184"], ["220185", "220186", "220187", "220188"], ["220189", "220190", "106379"]][["106373", 15],...
View ArticleWhat is the '
Example:sentence = <<~ LOTSOFWORDSthis is an example of the thing initialising a variable, how else does this work?LOTSOFWORDSI don't think it's the shovel operator, there's no tilde in that. I'm...
View ArticleUpload base64 encoded image with paperclip - Rails
Using cropit I get the image bas64 encode on rails through params. image = params['image'].gsub('data:image/jpeg;base64,', '') decoded_file = Base64.decode64(image)and then I save to amazon s3 with...
View Article