0
0

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 5 years have passed since last update.

NoMethodError undefined method `xxx' for nil:NilClass

0
Posted at

contoller側で定義した変数が全てnil:NilClass

routes.rbが間違っているわけではない。(というか開発中は表示できてた)

NoMethodError in Hoge#index
Showing /fuga/app/views/hoge/index.html.erb where line #14 raised:
undefined method `each' for nil:NilClass

controllerのタイポが原因だった

hoge_controller.rb
class HogeController < ApplicationController
  before_action :set_user, only: [show] // 「:」が抜けている :show

only: [:show]としたら表示された。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?