使用其他页面上的devise登录名

问题描述 投票:0回答:1

我正在尝试将设备登录名添加到另一个页面,但是每次我点击提交按钮时,它都会重定向到主要的设备登录页面。我尝试过使用f.submit

<%= button_tag(type: 'submit') do %>
  <span>GO</span><i class="fa fa-check"></i>
<% end %>

下面是完整的html

<div class="box">

  <div class="title">LOGIN</div>

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

        <div class="input">
            <label for="name">Email</label>
              <%= f.email_field :email, autofocus: true, autocomplete: "email", name: "name", id: "name"%>
            <span class="spin"></span>
        </div>

        <div class="input">
            <label for="pass">Password</label>
            <%= f.password_field :password, autocomplete: "current-password", name: "pass", id: "pass" %>
            <span class="spin"></span>
        </div>

        <div class="button login">
            <%= button_tag(type: 'submit') do %>
              <span>GO</span><i class="fa fa-check"></i>
            <% end %>
        </div>

        <%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
          <%= link_to "Forgot your password?", new_password_path(resource_name), class: "pass-forgot" %>
        <% end %>
    <% end %>
</div>

Application_helper.rb

module ApplicationHelper
  def resource_name
    :user
  end

  def resource_class 
     User 
  end

  def resource
    @resource ||= User.new
  end

  def devise_mapping
    @devise_mapping ||= Devise.mappings[:user]
  end
end

注册工作正常,但是如果出现错误,它也会重定向到设计页面。我遵循了一些有关此的教程,但是找不到解决方案。

html devise ruby-on-rails-5
1个回答
0
投票

我找到了解决方案。要解决此问题,我需要做的就是从表单字段中删除name:

© www.soinside.com 2019 - 2024. All rights reserved.