0
私はdeviseを使用しており、どのタイプのユーザーがサインインされているかを確認するためのヘルパーメソッドを設定しています。私はプレーヤーとコーチのユーザータイプがあり、current_playerとcurrent_coachは、 。ここで誰かがサインインしているかチェックしてください
は私application_controllerです:
helper_method :current_account, :account_signed_in?
def current_account
if @current_player
@current_account = current_player
elsif @current_coach
@current_account = current_coach
end
end
def account_signed_in?
current_account != nil
end
選手とコーチのモデルは、ユーザモデルのサブモデルです。
class Player < User
end
class Coach < User
end
これは動作します(ただし、current_playerがある場合のみ):
wrong number of arguments (given 10, expected 2)
@current_player
と@current_coach
がnil(または偽)であることを意味します私は@ – user2759575より多くのコードを削除します:current_playerとcurrent_coachはどこから来ますか? – Fred
彼らは開発者から来ました。私はstiを使用しています。プレーヤーとコーチはユーザーモデルのサブモデルです。 – user2759575