Getting: “Couldn't find SessionsHelper, expected it to be defined in helpers/sessions_helper.rb”

后端 未结 5 879
予麋鹿
予麋鹿 2021-01-19 07:58

I am getting the following in my log file upon loading /login/.

Started GET \"/login\" for 120.138.93.108 at 2016-01-02 03:06:24 +0000

Act

5条回答
  •  滥情空心
    2021-01-19 08:40

    TL; DR

    Sometimes it's not the problem of helpers. Delete all the helpers and see what happens next.

    Body

    It seems if the loading (reading the class file, eval the content to define the class/module defined inside) of the controller itself fails with whatever reason, it shows this error.

    In my case, there was a class from a gem which was intended to be used by includeing to the controller, which overrides included method, and did some initialization process. The problem was, this include method raised an exception, which prevented the Controller to get loaded, and I don't know why but resulted in a situation just like as described in this question.

    I found out the root cause by deleting all the helpers and checking what happens next. If error changes and you find it to be happening on the loading of the Controller, then now you can fix it.

    # Example class of what have caused the Helper not found in my case
    class FooController
      include SomeGemWhichRaiseExceptionOnInclude
    end
    

提交回复
热议问题