-2
<div class="row">
<div class="span6 offset3">
<%= form_for(:session, url: sessions_path) do |f| %>

  <%= f.label :email %>
  <%= f.text_field :email %>

  <%= f.label :password %>
  <%= f.password_field :password %>

  <%= f.submit "Sign in", class: "btn btn-large btn-primary" %>
<% end %>

<p>New user? <%= link_to "Sign up now!", signup_path %></p>

上面的 Rails 代码是如何变成下面的 HTML 代码的?

<form accept-charset="UTF-8" action="/sessions" method="post">
  <div>
    <label for="session_email">Email</label>
    <input id="session_email" name="session[email]" size="30" type="text" />
  </div>
  <div>
    <label for="session_password">Password</label>
    <input id="session_password" name="session[password]" size="30" 
           type="password" />
  </div>
  <input class="btn btn-large btn-primary" name="commit" type="submit" 
       value="Sign in" />
</form>
4

1 回答 1

0

看看Rails 表单助手

于 2013-01-15T18:27:14.083 回答