From 36fc20bf72b638ac5e10d81c1a016038051c48d3 Mon Sep 17 00:00:00 2001 From: Dimitar Haralanov Date: Tue, 17 Oct 2023 12:58:24 +0200 Subject: [PATCH] Add Ruby 3 support to the example app In Ruby 3.0, positional arguments and keyword arguments are separated. This is a breaking change and requires code changes. Rails has solved that compatibility change in 6.1, but the changes have not been ported to 6.0. This commit updates Rails to 6.1 and: - It explicitly adds the webrick gem to the Gemfile since it no longer comes bundled with Ruby 3.0 - It changes `File.exists?` to `File.exist?` since the former is not available in Ruby 3.0 --- example/Gemfile | 3 ++- example/config/boot.rb | 2 +- example/db/schema.rb | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/example/Gemfile b/example/Gemfile index 6d8373d..bc08175 100644 --- a/example/Gemfile +++ b/example/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' -gem 'rails', '6.0.2.1' +gem 'rails', '6.1.5' gem 'bootstrap-sass' gem 'jquery-rails' @@ -10,5 +10,6 @@ gem 'rspec-rails' gem 'sass-rails', '~> 5.0.0' gem 'slim' gem 'sqlite3' +gem 'webrick', '~> 1.8' gem 'will_paginate' gem 'will_paginate-bootstrap' diff --git a/example/config/boot.rb b/example/config/boot.rb index 3596736..5e5f0c1 100644 --- a/example/config/boot.rb +++ b/example/config/boot.rb @@ -1,4 +1,4 @@ # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/example/db/schema.rb b/example/db/schema.rb index e98c497..f0501c2 100644 --- a/example/db/schema.rb +++ b/example/db/schema.rb @@ -2,8 +2,8 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `rails -# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. @@ -27,7 +27,7 @@ end create_table "users", force: :cascade do |t| - t.string "name", limit: 255, null: false + t.string "name", null: false t.datetime "created_at" t.datetime "updated_at" t.index ["name"], name: "index_users_on_name", unique: true