Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Browsing all 4634 articles
Browse latest View live

How do I round a float to a specified number of significant digits in Ruby?

It would be nice to have an equivalent of R's signif function in Ruby.For example:>> (11.11).signif(1)10>> (22.22).signif(2)22>> (3.333).signif(2)3.3>> (4.4).signif(3)4.4 # It's...

View Article


how to count number of specific nodes with iReport 5.0.0?

i've a ruby on rails application, version 3, and i generate this report using iReport 5.0.0. I need count how much itens are inside de the "mov-comps" array, and store the value inside some variable on...

View Article


What causes NameError in Game Object?

I am learning OOP with Ruby. I have 2 classes - Game & Player.Player and Computer are to be created for Tick-Tack-Toe game. My idea is to use Player class to create a player and a computer for the...

View Article

Add a default value to a column through a migration

How do I add a default value to a column that already exists through a migration? All the documentation I can find shows you how to do it if the column doesn't already exist but in this case it does.

View Article

Best way to convert strings to symbols in hash

What's the (fastest/cleanest/straightforward) way to convert all keys in a hash from strings to symbols in Ruby?This would be handy when parsing YAML.my_hash = YAML.load_file('yml')I'd like to be able...

View Article


AWS CodeArtifact for Ruby gems

Based on the AWS CodeArtifact FAQ https://aws.amazon.com/codeartifact/faq/ I do not see Ruby gems in the list of features. Is it possible to use AWS CodeArtifact instead of Gemfury?

View Article

Issue with polars-df gem in Alpine-based Docker image

I am working on a Ruby project and using the polars-df gem. My application is dockerized and I am using an Alpine-based Docker image. However, I am encountering an error related to the polars-df gem...

View Article

【Rails】There is method that can be called on the rails console but not on the...

Rails 6.1.4.7ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]codeRegularEvent's holding_today? method calls the EventSchedule module (original).app/models/regular_event.rbclass...

View Article


How do I extract a sub-hash from a hash?

I have a hash:h1 = {:a => :A, :b => :B, :c => :C, :d => :D}What is the best way to extract a sub-hash like this?h1.extract_subhash(:b, :d, :e, :f) # => {:b => :B, :d => :D}h1...

View Article


Find last created_at record

How can I find the last record by their created_at field? Record.order("created_at").lastor Record.where(:created_at).lastor Neither and there is a better way?

View Article

How to fix 'no implicit conversion of nil into String' installing react...

I upgraded react native from 0.72 to 0.73.8, but when I try to install the pods with pod install I get the following error:Downloading dependenciesGenerating Pods projectSetting USE_HERMES build...

View Article

Rails 5.2.3 converting all params datatype to string when testing using rspec

I am using rails 5.2.3 and testing using rspec-rails (3.8.2), when I send request to rails like this let(:params) do { down_payment: 10_000, asking_price: 100_000, payment_schedule: 'weekly',...

View Article

How to configure GRPC client retry for Ruby via Service Config

so i have been stuck on how configuring GRPC client retry on Ruby. The code to reproduce is taken from https://github.com/grpc/grpc/tree/master/examples/ruby/errors_and_cancellationThe pb files can be...

View Article


How to temporarily redefine a method in Ruby?

Say, I have:class Test def initialize(m) @m = m end def test @m endendHow can I temporarily make method #test of all instances (both existing and new ones) of Test return 113, and then restore the...

View Article

Send additional data to Workday

I am working on sending some additional data for a workday using this endpoint Edit_Worker_Additional_Data. However, it lacks the documentation as what type of data they are expecting, hence, I am...

View Article


PG::ConnectionBad - could not connect to server: Connection refused

Every time I run my rails 4.0 server, I get this output. Started GET "/" for 127.0.0.1 at 2013-11-06 23:56:36 -0500PG::ConnectionBad - could not connect to server: Connection refusedIs the server...

View Article

Rails Sets a Cookie on a Subdomain for GET Requests but Not for POST Requests

I have a subdomain b.test.com that makes request to another subdomain a.test. When the request is GET type the cookie and session are set correctly in b.test but if I change to POST they are no longer...

View Article


Why can't rbenv install the latest Ruby version on Ubuntu?

I want to install a recent version of Ruby on Ubuntu 20.04.But when I run rbenv install -l on my Ubuntu server, I only see old versions of Ruby listed.Available versions: 1.8.5-p52 ... 2.2.7 2.3.0-dev...

View Article

Why won't this code allow me to hide a pdf file "inside" of a png file using...

I'm trying to hide a file called "hello_world.pdf" inside of an image file "kitten.png". The code I'm using is:original_image_file = File.read("kitten.png")hidden_file =...

View Article

Before-filter for all POST requests in Sinatra?

Is there a way to create a "before" filter to capture and pre-process all POST requests in Sinatra?

View Article
Browsing all 4634 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>