Questions tagged [ruby-3]
For issues relating to development in Ruby, version 3. If your question applies to Ruby in general, use the tag [ruby].
86
questions
0
votes
1
answer
24
views
Rails admin with zeitwerk
Hi i am having a application built in rails 6 and i am trying to update it to rails 7 but there's some problem i am facing with zeitwerk.
in the rails admin initilizer
# initilizer/rails_admin.rb
...
0
votes
1
answer
14
views
LoadError when using bundle exec to run a script in Ruby 3 (using rvm)
The following Ruby script gives me a LoadError when it requires the activesupport gem, but everything else is showing me that it's installed. I get the same error whether I run it through bundle exec ...
1
vote
0
answers
39
views
Handling args and kwargs Ruby 3.0 and 3.1 with Rspec
I am doing an upgrade from Ruby 3.0.6 to Ruby 3.2.2 on our project, and I ahve encountered a weird issue that I tried to understand for past few days.
We are using RSpec for tests and in one of the ...
-1
votes
0
answers
29
views
Ruby Regex exact match "e-" words with word boundaries [duplicate]
I am using the following code to match keywords in a string.
text.match(/\b#{keyword}\b/)
Since it uses the - as word boundary it matches the word commerce in a string e-commerce website. What I want ...
0
votes
1
answer
60
views
rails credentials inside of docker is no longer opening
My rails environment runs from a Docker. Previously using a Docker ruby:2.7.5 (when I created th project credential, but I think it doesn't matter), and currently using ruby:3.2.2.
Suddenly, when I ...
1
vote
0
answers
32
views
Significantly slower DB queries between Ruby 2.7.6 (heroku-20) and Ruby 3.1.4 (heroku-22)
I have a Ruby 2.7.6 app running on Heroku (stack heroku-20) and a branch of the same app on Ruby 3.1.4 running on Heroku (stack heroku-22). Both have identical DBs. Running these two branches locally, ...
0
votes
0
answers
108
views
Process jobs with Sidekiq Scheduler
I'm not sure what I'm missing with my Sidekiq Scheduler setup. I can process jobs manually, but the scheduled jobs aren't running. Pressing Enqueue Now from the Web ui runs the job correctly. Starting ...
1
vote
2
answers
48
views
Getting all nested objects belongs to a model
I have a Location model that can have many sublocations, or one parent location.
Let's say location-A is a parent location, has location-B and location-C as sublocations. But location-B also has a ...
0
votes
1
answer
72
views
Ruby IPAddr class accepting wrong IPv6 address string
We are middle of upgrading ruby versions v2.7.3 -> v3.1.3
One of our test cases are failing related to valid ipv6 address string, check the following
# ruby 2.7.3
IPAddr.new('fe80::85e:7530:69ec:...
1
vote
2
answers
145
views
Default values when pattern matching a hash in Ruby 3
In Ruby 3,
hash => {a:}
works similarly to JS
{ a } = hash
except it throws an exception if :a isn't a key in hash instead of assigning a = nil. Ok, we can do
hash => {a:} rescue nil
except ...
0
votes
1
answer
431
views
Unable to Install Ruby 3.0.2 on Ubuntu 22.10
I've tried using both Ruby Version Manager (RVM) and RBENV to install 3.0.2 and both times I get some kind of Make error, but can't make heads or tails of the log files.
Here is the console log for ...
0
votes
0
answers
73
views
Uninitialized constant for autoload_paths when migrate to Rails 6
I have project on ruby 2.6.2 and rails 5.2.3.
I successfully migrate to ruby 3.1.3.
And now try migrate to Rails 6.1.7.3.
But when I try to run rails c, I get next exception:
uninitialized constant ...
2
votes
1
answer
193
views
Upgrading to haml 6 causes ActionView::Template::Error (undefined method `safe_concat' for {:add_to_stack=>true}:Hash) error
We are using haml 5.2.2 + Ruby 3.2 + Rails 7 + haml-rails 2.1 in our app.
When I to upgrade to haml 6.1.1, my rails views start failing with the exception:
ActionView::Template::Error (undefined ...
1
vote
1
answer
1k
views
Ruby 3.0 - wrong number of arguments (given 3, expected 1..2)
We have a project that is using the uk_postcode gem. There is a validator class as follows:
class UkPostcodeValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
...
0
votes
2
answers
402
views
Binding.pry not showing the stopping point in console after ruby 3 upgrade
I am new to ruby, we have a ROR microservice(rails version 6.1) , recently i updated the ruby version on the service from 2.7 to 3.0 , after this since there were failures and i wanted to debug it, so ...
1
vote
1
answer
255
views
Sweet Alert 2 is not working properly in Rails 7 Application
I attempted to integrate the Sweet Alert 2 java-script library for customising standard alert boxes into a Rails 7 application, but I received the following error message: "Swal is not defined.&...
6
votes
2
answers
2k
views
Ruby 3.0.4 with Postgres 14 throws segmentation fault
I have
Ruby 3.0.4
Rails 6.1.7
pg 1.4.5
postgresql 14.6
Here is my database.yml file
development:
adapter: postgresql
encoding: utf8
database: olio_development
username: postgres
password: password
...
2
votes
1
answer
6k
views
rbenv and Apple m1. Failed installing ruby 3.2, 2.7 and 2.6
I can't install any ruby version with rbenv. I tried 2.6.10 2.7.7 or 3.2.0 .
This is the error I got when executing:
❯ rbenv install 3.2.0
To follow progress, use 'tail -f /var/folders/4v/...
0
votes
2
answers
136
views
boolean field not updating in Rails
I am building a basic crud app; with my controller method for updating a task as follows :-
def update
@task = Task.find(params[:id])
respond_to do |format|
if @task.update(task_params)...
0
votes
2
answers
373
views
Is it possible to pattern match on a hash value to get the hash key in Ruby 3?
This is a question about pattern matching in Ruby 3.
I have a hash:
h = {
x: [1, 2, 3],
y: [11, 12, 13],
z: [100, 101],
}
Given an integer (for example, 13), I'd like find the hash key whose ...
0
votes
0
answers
64
views
sidekiq - runaway FIFO pipes created with large job
We are using Sidekiq to process a number of backend jobs. One in particular is used very heavily. All I can really say about it is that it sends emails. It doesn't do the email creation (that's a ...
3
votes
2
answers
227
views
Ruby 3 collecting results from multiple scheduled fibers
Ruby 3 introduced Fiber.schedule to dispatch async tasks concurrently.
Similar to what's being asked in this question (which is about threaded concurrency) I would like a way to start multiple ...
0
votes
0
answers
172
views
Multiple files with the same output path cannot be linked ("actiontext.css")
using: ruby 3.1.2p20 and Rails 7.0.2.3
after updating the application from rails 6 to 7 its giving the following error after starting the application:
ActionView::Template::Error (Multiple files with ...
0
votes
0
answers
90
views
Capybara - assert against string containing HTML entities?
In a page on my Rails 6 app, I have table cells rendered from the database, and sometimes the text in them is rendered with converted fancy quotes or other HTML entities encoded by our own t method, ...
2
votes
1
answer
248
views
Why do Ruby fibers that run sequentially without a scheduler set run concurrently when a scheduler is set?
I have the following Gemfile:
source "https://rubygems.org"
ruby "3.1.2"
gem "libev_scheduler", "~> 0.2"
and the following Ruby code in a file called main....
2
votes
2
answers
162
views
How to use HEREDOC to pass as an argument to a method?
Code example:
create_data_with(
first: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
second: <<~TEXT
Aenean vel ex bibendum, egestas tortor sit amet, tempus lorem....
0
votes
1
answer
395
views
Ruby - Check if datetime string is in proper format? [closed]
What is a clean way to confirm if a string datetime is in the proper format in ruby 3? example input is:
datetime = "2020-02-25T02:57:08.264Z"
I looked through the Time class and couldnt ...
0
votes
1
answer
3k
views
Why am I getting `ArgumentError: wrong number of arguments (given 1, expected 0)` on save?
I have this method that gives me a error ArgumentError: wrong number of arguments (given 1, expected 0) after upgrading to ruby 3.1 at test.save!.
def seed_test_program
test = TestProgram....
6
votes
4
answers
462
views
Ruby 3 IRB home end and ctrl-u not working
I've recently started using Ruby 3 more and it seems the home key (to take me to the beginning of the line) the end key (end of the line) and ctrl-u (clear the line) aren't working.
I'm running Arch ...
1
vote
1
answer
2k
views
Authlogic NameError - wrong constant name Object.const_get(camel_cased_word)
I am trying setup Authlogic gem with rails 7. I have simple controller:
class UsersController < ApplicationController
def new
render_page 'Registration'
end
def create
@user = User....
0
votes
1
answer
608
views
After upgrading to Ruby 3, unable to pass multiple arguments to my "initialize" method
I recently upgraded to Rails 6 with Ruby 3. I have this in a controller
my_object = MyObject.new(my_object_params, @header)
The object “initialize” method is defined like so
def initialize(params, ...
3
votes
1
answer
95
views
Puma causes Ruby 3 Debug to show ANSI escape sequences when pressing arrow keys (Mac ZSH)
I'm on Mac OS 12.3.1 using Z shell.
When using the Ruby Debug gem (1.5) in Puma 5.6.4 with Ruby 3.0.0 the arrow keys do not work and instead print out the ANSI escape sequences (e.g. ^[[A for up). If ...
5
votes
1
answer
2k
views
undefined method `escape' for URI:Module in ruby 3
After updating my Rails application from Rails 6.0.1 to Rails 7.0.2.3
I am getting issue with the gem "paperclip", '~> 6.1.0'
while using it in application is gives error:
ActionView::...
1
vote
2
answers
3k
views
Docker: TCP/IP connections on port 5342? connect to server: Connection refused Is the server running on host
I am using rails 3.0.0 with rails 7.
My dockerfile is as:
FROM ruby:3.0.0-alpine
RUN apk add --update --virtual \
runtime-deps \
postgresql-client\
build-base \
libxml2-dev \
...
0
votes
1
answer
756
views
How to avoid sending emails in Rails test-env with sendgrid-ruby?
Problem
I seem to be facing a stubborn issue with my RSpec tests trying to constantly send emails in test-env despite my configuration should avoid it. Whatever I try it seems to totally ignore it.
My ...
3
votes
4
answers
4k
views
Troubles upgrading from ruby 2.7 to 3.0 - error: use of undeclared identifier 'RUBY_FUNCTION_NAME_STRING'
I've been struggling with trying to upgrade rails 3.0 for about a week now.
I'm not entirely sure what the issue is but I was thinking it could be due to the fact that I have both rvm and rbenv.
I've ...
0
votes
0
answers
785
views
facing ERROR: ArgumentError: wrong number of arguments (given 3, expected 2) ruby 3 aruba
after upgrading ruby from 2.7 to 3.0 to 3.1 I am facing fowling issue while running the cucumber test
Given a local mode chef repo with nodes 'one,two,three' ...
6
votes
2
answers
3k
views
`require': Cannot load such file -- rdoc (LoadError)
While trying to run the "irb", I ran into this error:
<internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- rdoc (LoadError)
...
5
votes
1
answer
506
views
What's the replacement for acts_as_commentable in Rails 6, Ruby 3.0.2?
I upgraded our app to Rails 6.1.4.4 and Ruby 3.0.2. I have this old gem
gem 'acts_as_commentable'
Locked at version 4.0.2. The gem does not appear to be supported anymore, which is a shame because ...
2
votes
1
answer
69
views
How to configure Ocotshark (connection pooling) to work with Ruby 3 and Rails 6.1?
I’m using Rails 6.1.4.4, Octoshark 0.3.0, and just upgraded to Ruby 3.0.2. Now when starting Rails console, I get
/Users/myuser/.rvm/gems/ruby-3.0.2/gems/activerecord-6.1.4.4/lib/active_record/...
1
vote
2
answers
3k
views
rails new creates Rails 7.1-alpha instead of Rails 7.0
i am just wondering. I want to create a new rails app and have following setup on my linux system:
ruby 3.0.3 via RVM
yarn v1.22.17
and
gem install bundler -v 2.2.33
gem install rails -v 7.0.0
If ...
1
vote
1
answer
129
views
Ruby's array min returning value, not array
In Ruby (3.0.1) the min function on an array
Returns one of the following:
The minimum-valued element from self.
A new Array of minimum-valued elements selected from self.
(from here).
So, given
l =...
2
votes
1
answer
2k
views
Updating to Ruby 3.0.x with Rails: symbol not found in flat namespace '_RHASH_EMPTY_P'
Having issues upgrading my rails project on my M1 Mac related to Debase not compiling due to symbol not found in flat namespace '_RHASH_EMPTY_P'
OS: Monterey 12.0.1
Machine: Mac mini (m1, 2020)
Ruby ...
14
votes
3
answers
13k
views
MacOs (M1 Arm64) unable to load Nokogiri - Using system default Ruby
I could use some help here. I'm setting up a new 2020 Macbook Pro M1.
I've completed all the regular steps to install ruby/rails on a Mac, however I'm unable to complete rails new. Upon hitting the ...
1
vote
1
answer
304
views
Can I use Ruby 2.4 code in Ruby 3 without getting any error?
I was wondering if I could use codes based on ruby 2.4 in ruby 3 (as in the programs, methodology, syntax and function names). I would like to slowly migrate to Ruby 3, but I would like to know if ...
-2
votes
2
answers
165
views
remove last character from looping Hash
can you help me to solve this problem with this code?
total_user_input = []
while true
print "Field Name: "
user_input = gets.chomp
break if user_input.empty?
total_user_input <&...
1
vote
1
answer
403
views
Unable to install rmagick on Ruby 3.0.2
I am trying to update our Ruby version from 2.7.4 to 3.0.2. If I bundle locally on my machine, I get this error:
rmimage.c:12960:1: error: implicit declaration of function 'C__Bool_to_R__Bool' is ...
5
votes
1
answer
875
views
How to configure Steep to find RBS files for a gem outside the stdlib?
Cannot find type `Sinatra::Base`
ruby file
class StaticApp < Sinatra::Base
end
rbs file
class StaticApp < Sinatra::Base
end
run
bundle exec steep check --log-level=fatal
result
[error] ...
0
votes
0
answers
254
views
Rails file upload "TypeError: can't dump File"
We are working on updating the ruby version from 2.3.1 to 3.0.2 and related changes.
We are facing an issue while uploading a file.
I have just set the form of file upload and set upload event without ...
0
votes
2
answers
552
views
Read entire message from a TCPSocket without hanging
I'm putting together a TCPServer in Ruby 3.0.2 and I'm finding that I can't seem to read the entire packet without blocking (until the socket is closed).
Edit: There was some confusion on what I was ...