To briefly explain devise, it is a gem that does a login system.
The devise helper method authenticate_user! Method is a method that can be executed only by the logged-in user by describing it in the controller as before_action.
Write the authenticate_user! method on the controller. Example
class PostsController < ApplicationController
before_action :authenticate_user!
def index
end
end
If you write like this, only the logged-in user can process with posts_controller.
Example
class PostsController < ApplicationController
before_action :authenticate_user!, only: [:show]
def index
end
def show
end
end
By writing this way, you can prevent unlogged-in users from using only the show action.
I would appreciate it if you could point out any mistakes. Thank you for watching until the end.
Recommended Posts