form_for在设计如何工作? [英] form_for in devise How it works?
本文介绍了form_for在设计如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
rails g devise:views命令生成该视图
rails g devise:views command generated that view
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :username %><br />
<%= f.text_field :username, :autofocus => true %></div>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></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 "devise/shared/links" %>
我的问题是它的工作原理form_for(resource,:as => resource_name,...
My question is how does it work " form_for(resource, : as=>resource_name, ..."
推荐答案
资源
是一个简单的记录(或对象)对于Devise而言,它通常被称为 User
或类似的内容。 form_for
的其余参数是选项,详见 form_for docs。
resource
is simple a record (or object) - with respect to Devise, it's usually something called User
or similar. The rest of the parameters for form_for
are options, detailed in the form_for docs.
这篇关于form_for在设计如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文