Some setup you must do manually if you have n‘t yet:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config / environments / development.rb:
<% if devise_mapping.rememberable?-%>
<div class = "form-group">
<% = f.check_box: remember_me%>
<% = f.label: remember_me%>
</ div>
<% end-%>
<div class = "actions">
<% = f.submit "Login", class: "btn btn-primary"%>
<% = link_to "Forgot Password", new_password_path (resource_name), class: "btn btn-link"%>
</ div>
<% end%>
</ div>
</ div>
(8) In order to protect our methods, add a login verification app / controllers / application_controller.rb before each method
class ApplicationController <ActionController :: Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use: null_session instead.
protect_from_forgery with:: exception
before_action: authentica
te_user!
end
(9) For some pages that can be published without login, add a statement that skips verification in the controller
class ProductsController <ApplicationController
skip_before_action: authenticate_user !, only: [: index,: show]
Add login registration function for the application ruby on rails
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.