加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 也可以在主页上设计注册表单

发布时间:2020-12-16 20:08:59 所属栏目:百科 来源:网络整理
导读:我想要在我的应用程序主页#索引的主页以及Devise创建的默认页面上显示sign_up表单. Devise有指示为sign_in页面执行此操作,但如何使用sign_up? https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
我想要在我的应用程序主页#索引的主页以及Devise创建的默认页面上显示sign_up表单.

Devise有指示为sign_in页面执行此操作,但如何使用sign_up?
https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app

谢谢!

解决方法

将其粘贴到您的home#索引视图代码中
<h2>Sign up</h2>

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

  <div><%= f.label :email %><br />
  <%= f.email_field :email %></div>

  <div><%= f.label :password %><br />
  <%= f.password_field :password %></div>

  <div><%= f.label :password_confirmation %><br />
  <%= f.password_field :password_confirmation %></div>

  <div><%= f.submit "Sign up" %></div>
<% end %>

<%= render "links" %>

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

在您的应用程序助手文件中.你已准备好出发.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读