Rails 7 gem devise

2022-09-14  本文已影响0人  Zee_jin

加入:gem "devise", github: "heartcombo/devise"

 指令: bundle install

            rails generate devise:install

在config/environments/development.rb

Rails.application.configure do

加入:config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

在app/views/layouts/application.html.erb

<body>

加入:    <p class="notice"><%= notice %></p>

加入:   <p class="alert"><%= alert %></p>

    <%= yield %>

  </body>

指令:rails generate devise user

            rake db:migrate

            rails generate devise:views

将app/views/devise/registrations/new.html.erb

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>

修改为:<%= form_for(resource, as: resource_name, url: registration_path(resource_name), data: {turbo: false}) do |f| %>

上一篇下一篇

猜你喜欢

热点阅读