Gemfileのバージョン変更
- gem "rails", "~> 7.0.2", ">= 7.0.2.3"
+ gem 'rails', '~> 6.0.4', '>= 6.0.4.7'
コマンド実行
$ bundle update
$ rails app:update (全てYES)
$ rails s -b 0.0.0.0
するとエラー起きるので、以下2点修正。
Gemfileにgem ‘listen’追加
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
gem 'listen'
end
config.ruからRails.application.load_server削除
config.ru
- Rails.application.load_server
マイグレーションしていきます。
$ rails db:reset
$ rails db:migrate
rails aborted!
ArgumentError: Unknown migration version "7.0"; expected one of "4.2", "5.0", "5.1", "5.2", "6.0"
db/migrate/****_create_users.rb
- class CreateUsers < ActiveRecord::Migration[7.0]
+ class CreateUsers < ActiveRecord::Migration[6.0]
rails aborted!
NoMethodError: undefined method `define' for #ActiveRecord::Migration:0x0000ffff82c040e0
Did you mean? defined?
db/schemes.rb
- ActiveRecord::Schema[7.0].define(version: 2022_03_30_XXXXX) do
+ ActiveRecord::Schema.define(version: 2022_03_30_XXXXX) do
rails aborted!
NameError: undefined local variable or method `primary_abstract_class'
models/application_record.rb
class ApplicationRecord < ActiveRecord::Base
- primary_abstract_class
+ self.abstract_class = true
end
再度$ rails s -b 0.0.0.0
実行し、http://localhost:3000/に表示される
やったー!!