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
1
vote
2 answers

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 this gives undesired result if some keys are present and…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
1
vote
1 answer

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) postcode = UKPostcode.parse(value.to_s) return…
Risha
  • 15
  • 5
1
vote
1 answer

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." I'm using Ruby 3 and Rails 7. I initially attempted to…
1
vote
1 answer

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…
idan ahal
  • 707
  • 8
  • 21
1
vote
1 answer

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.new(email: 'codcore@gmail.com', password: 415561) …
Kavachaj
  • 411
  • 1
  • 4
  • 15
1
vote
2 answers

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 \ libxslt-dev \ yarn \ libffi-dev \ …
vidur punj
  • 5,019
  • 4
  • 46
  • 65
1
vote
2 answers

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 I create a new app via rails new my_app -T…
F.M.
  • 193
  • 2
  • 8
1
vote
1 answer

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 = [{n: 1, m: 6}, {n: 1, m: 5}, {n: 2, m: 4}, {n:…
dumbledad
  • 16,305
  • 23
  • 120
  • 273
1
vote
1 answer

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 everything would be stable. Do I need to download…
1
vote
1 answer

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 invalid in C99…
linkyndy
  • 17,038
  • 20
  • 114
  • 194
1
vote
0 answers

upgrading rails 4.2.7 to rails 6.0.4.1, postgres jsonb column data returning as empty hash {} despite having data in column

Found an issue with jsonb column data Rails 4.2 and ruby 2.10, we are able to fetch jsonb column named data but not in the latest Rails 6.0.4.1 and ruby-3.0.2, it returning empty hash despite having data in the column Can any body help me please to…
raj_acharya
  • 665
  • 5
  • 17
1
vote
0 answers

OpenSSL::SSL::SSLError after rails 6.0 with ruby 2.7 -> to rails 6.1 with ruby 3.0

I have updated my rails 6.0.4 app to 6.1.3.2 and ruby from 2.7.3 to 3.0.1 On sending a test email in development I get an error: OpenSSL::SSL::SSLError hostname "mail.ABCD.com" does not match the server certificate I have not changed my…
Daniela
  • 234
  • 2
  • 13
1
vote
1 answer

Undefined method arity when starting rails server (rails 6.1 and ruby 3.0.0)

Trying to upgrade an existing rails application to ruby 3.0 from ruby 2.7.2. Getting an error when trying to start the server with rails s. Here are the full logs for the error: rails s => Booting Puma => Rails 6.1.3.1 application starting in…
mattjarn
  • 41
  • 5
1
vote
0 answers

after changing ruby version getting a frozenobject error

i have a code in ruby 2.7.2 where it is working fine. but after changing ruby version to 3.0.0 it is giving cannot modify FrozenObject error at line 275. as i have checked $? is a Frozen Object in ruby 3.0.0 but it is not Frozen in ruby 2.7.2 so…
1
vote
1 answer

How to express this data type in Ruby?

I have this preudo code that describes a type type MyType1 = { type: :type1, field1: number, field2: any } | { type: :type2, field3: string } | { type: :type4, field4:…
Khinkala2
  • 11
  • 1