1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

rails7からrails6にダウングレードした

Posted at

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/に表示される
image.png

やったー!!

1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?