Home>


I am studying in the "Quick Practice Guide". Currently, we are creating a task management application for Chapter4.

I want to be able to use task management without logging in.

I want to check if the user is logged in with a filter that is processed before the action written by the task management function. If the user is not logged in, I want to redirect to the login screen and make the task management function practically unavailable.

I'm in trouble without knowing why login was defined.

・ Addbefore_action: login_requiedtoapp/controllers/application_controller.rb

Whenskip_before_action: login_requiredwas added to

app/controllers/sessions_controller.rb, I encountered the following error.

Error message
ArgumentError
Before process_action callback: login_required has not been defined
class SessionsController
Applicable source code

application_controller.rb

class ApplicationController


app/controllers/sessions_controller.rb

Class SessionsController

skip_before_action: login_required
skip_before_action: login_required, raise: falsewas changed to a redirect loop.

Please describe what you tried for the problem here.

Supplemental information (FW/tool version etc.)

ruby ​​2.6.3 rails 2.5.3
Please include more detailed information here.

  • Answer # 1

    I'm in trouble without knowing why login was defined.
    But
    : login_required has not been defined
    : Login_required has not yet been defined
    It is an error.

    def Please define login_required.

Trends