本文介绍了在主页上设计注册表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够在我的应用程序主页上显示注册表单home#index
以及 Devise 创建的默认页面.
I want the ability to display the sign_up form on the homepage of my app home#index
as well as the default page Devise creates.
Devise 有针对 sign_in 页面执行此操作的说明,但我如何使用 sign_up 执行此操作?https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
Devise has the instruction to do this for the sign_in page but how can I do it with sign_up?https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-app
谢谢!
推荐答案
将此粘贴到您的 home#index
查看代码中
Paste this in your home#index
view code
<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
在您的 Application Helper
文件中.
你可以走了.
in your Application Helper
file.
You are good to go.
这篇关于在主页上设计注册表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!