LoginSignup
3
0

More than 1 year has passed since last update.

Ruby on Railsのrefileでwrong number of arguments (given 3, expected 2; required keyword: object)が発生したときの対処

Posted at

Rails初心者大学生です。
https://www.youtube.com/watch?v=uos2mowBrJA
こちらを元に、編集画面にrefileで画像アップロードをしようとした所、上記のエラーが吐かれたので奮闘しました。
再び同様の事態が起きても対処できるようにメモ。

環境

Ruby: 3.1.2
Rails: 7.0.2.4

原因

https://teratail.com/questions/313718
上記の回答によると、どうやらrefile自体が長らく保守されていないため、現在のバージョンに対応していないらしいです。

試したこと

バージョンダウンを試みました。rbenvを利用してインストールし、Gemfileの内容を変更。
Ruby: 2.7.6
Rails: 6.1.3.2

こちらで、「bundle install」を実行すると、

Bundler could not find compatible versions for gem "activesupport":
  In snapshot (Gemfile.lock):
    activesupport (= 7.0.2.4)

  In Gemfile:
    turbo-rails was resolved to 1.0.1, which depends on
      actionpack (>= 6.0.0) was resolved to 7.0.2.4, which depends on
        activesupport (= 7.0.2.4)

    rails (~> 6.1.3.1) was resolved to 6.1.3.2, which depends on
      activesupport (= 6.1.3.2)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

activesupportをrailsのバージョンと一緒にしないといけないらしいです。
なので、Gemfileの末尾に

gem "activesupport", "~> 6.1.3.1"

を記載して「bundle update」と「bundle install」を行うと、無事installには成功しました。

その後、サーバを立ち上げようと「rais s」を打った所、

undefined local variable or method `primary_class' for #<Class:0x00007f9f4c5e01d0> (NameError)

というエラーが発生。
https://qiita.com/khinatas3/items/b1970f0c5a54b0234543
こちらの記事を手順通りに進めると、無事バージョンダウンに成功し、refileのエラーも無くなりました。

3
0
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
3
0