LoginSignup
2
0

More than 3 years have passed since last update.

[Rails]ActiveHash使用の際のエラー(undefined method `current_scope' )

Posted at

はじめに

とてもしょーもないミスで1時間も浪費しましたので、二度と内容にこちらに備忘としてアウトプットいたします。

発生したエラー

以下のようなエラーが出ました。最初は誤字等を睨んだのですが、、そんなことはなく、、

スクリーンショット 2021-04-26 16.34.41.png

解決方法

こちらの一文を書くことを忘れていました。

game.rb
class Game < ApplicationRecord
#この一文
  extend ActiveHash::Associations::ActiveRecordExtensions 

 belongs_to :level;

ActiveHashを用いて、belongs_toを設定するには、
extend ActiveHash::Associations::ActiveRecordExtensionsと記述してmoduleを取り込む必要がありました。

終わりに

エラーが出たときは、基礎の基礎から立ち返ることをここに誓います(笑)
時間は大切に。

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