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].

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. Ruby 3.0 was released Dec 25, 2020.

For information on Ruby in general, visit . And API documentation for Ruby 3.0.0.

The official release 3.0 announcement summarizes the changes as:

  • Performance
    • MJIT
  • Concurrency
    • Ractor
    • Fiber Scheduler
  • Typing (Static Analysis)
    • RBS
    • TypeProf
82 questions
5
votes
3 answers

to_json on ActiveRecord object ruby 3.0

I am using rails 6.0.3.6 and ruby 3.0.0, When I call {'user' : User.first }.to_json I am getting "{\"user\":\"#\"}" same with [User.first, User.last].to_json If I switch back to ruby 2.7.2, I get proper result ie…
pk-n
  • 568
  • 4
  • 11
4
votes
1 answer

ArgumentError when upgrading from Ruby 2.7 to 3.0 - related to separation of positional and keyword arguments?

I am trying to upgrade gems from ruby 2.7.0 to 3.0.0. I have tried to read and plan ahead for what roadblocks I'd hit, like the Separation of positional and keyword arguments. I have updated two gems smoothly, but I have started to upgrade a third…
3
votes
2 answers

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 concurrent tasks on the fiber scheduler and once they…
Erik Madsen
  • 1,913
  • 3
  • 20
  • 34
3
votes
1 answer

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 I understand correctly, Puma is running on…
Jonathan
  • 61
  • 4
3
votes
4 answers

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 followed the upgrade tutorial from gorails here:…
2
votes
1 answer

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 method `safe_concat' for…
lucas
  • 1,050
  • 12
  • 21
2
votes
1 answer

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.rb: require 'libev_scheduler' set_sched = ARGV[0] == "--set-sched" if set_sched then …
Matt Welke
  • 1,441
  • 1
  • 15
  • 40
2
votes
2 answers

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. Ut sit amet rhoncus eros. Vestibulum ante ipsum primis in…
Colibri
  • 993
  • 11
  • 29
2
votes
1 answer

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/connection_adapters/abstract/connection_pool.rb:1043:in…
Dave
  • 15,639
  • 133
  • 442
  • 830
2
votes
1 answer

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 version: 3.0.2 Rails: 6.1.4.1 I've tried removing…
Josh Mathews
  • 198
  • 1
  • 15
2
votes
0 answers

ArgumentError (wrong number of arguments (given 2, expected 1)) upgrade to rails 6.1.3.2 / ruby 3.0.0

Below code has been failing while upgrading to rails 6.1.3.2 from rails 5.2.3 Project.all.each do |project| define_method("is_#{project.name}?".to_sym) { User.current_user.try(:projects) && User.current_user.projects.include?(Project.where(name:…
2
votes
1 answer

Issue with define_method in Ruby 3.0

I'm working on an upgrade from Ruby 2.7 to 3.0 and faced an issue with the keyword arguments change. Previously we used define_method in our code for some purposes. However, with the keyword arguments change, it can no longer handle an array of…
wwang
  • 59
  • 3
2
votes
1 answer

Need a handler. Pass the with: keyword argument or provide a block

Recently I update my app from Ruby version 2.6.1 to 3.0.1 & I'm using rbenv as a version manager. but when I try to run the rails server I got an error => Booting Puma => Rails 6.1.3 application starting in development => Run `bin/rails server…
Humayun Naseer
  • 440
  • 7
  • 18
1
vote
0 answers

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, DB query times seem similar. However on Heroku,…
Tony Beninate
  • 1,926
  • 1
  • 24
  • 44
1
vote
2 answers

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 sublocation location-D. How can I get all…
cnn
  • 13
  • 3