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_requied
toapp/controllers/application_controller.rb
skip_before_action: login_required
was added to・app/controllers/sessions_controller.rb
, I encountered the following error.
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: false
was 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
Related articles
- ruby - the last db setting doesn't work when deploying rails app on aws
- ruby on rails - i want to implement a function for administrator users to register luggage for general users in rails
- ruby on rails - mvc rails
- ruby on rails - rails6 rspec model run-time error nomethoderror: undefined method `valid?'for nil: nilclass
- ruby - rails tutorial chapter 2 (6th edition)
- ruby on rails - saved description in nested controller
- ruby on rails - cart function routing error cannot be resolved
- ruby on rails - rails s can't
- ruby on rails - how to transition from the top page
- ruby on rails - things associated with a foreign key cannot be called in view
- ruby on rails 5 - i want to update the received parameters with nil
- ruby on rails 6 - environment construction of ruby on rails
- ruby on rails 5 - actioncontroller :: invalidauthenticitytoken cannot be resolved
- ruby on rails - error in controller when transitioning with rails6 destory action
- ruby on rails - access fails after seed after deploying to heroku
- ruby on rails runtime error cannot be resolved
- ruby on rails - missing required keys: i'm having trouble resolving the [: id] error
- ruby on rails 5 - some items are not saved in db when posting from rails form
- bootstrap display in ruby on rails is broken
- ruby on rails - it is not saved in the database after registering the product
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.