Ruby on rails 在主页上设计注册表格
我希望能够在我的应用程序Ruby on rails 在主页上设计注册表格,ruby-on-rails,ruby-on-rails-3,devise,Ruby On Rails,Ruby On Rails 3,Devise,我希望能够在我的应用程序主页#索引的主页上显示注册表单,以及Desive创建的默认页面 Desive有为登录页面执行此操作的说明,但如何使用登录操作? 谢谢 将其粘贴到您的主页#索引中查看代码 <h2>Sign up</h2> <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %> <%= devi
主页#索引
的主页上显示注册表单,以及Desive创建的默认页面
Desive有为登录页面执行此操作的说明,但如何使用登录操作?
谢谢 将其粘贴到您的
主页#索引中
查看代码
<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" %>
在您的应用程序帮助文件中。
你可以走了。这是迪安的解释
另一个例子是表单和发布到用户会话路径:
session_路径(:user))do | f |%>
我把它放在我的新视图中作为我不得不使用的最后一行
,否则一切都好!同时将def resource\u class User end
添加到ApplicationHelper
我建议在同一页面上有相同表单时(即当用户在登录页面上时),手动将表单和字段的ID设置为语法正确。如果服务器端验证失败,我们如何知道下一页何时呈现?
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
<%= form_for(:user, :url => session_path(:user)) do |f| %>
<%= f.text_field :email %>
<%= f.password_field :password %>
<%= f.check_box :remember_me %>
<%= f.label :remember_me %>
<%= f.submit 'Sign in' %>
<%= link_to "Forgot your password?", new_password_path(:user) %>
<% end %>