0

使用由设计创建的用户模型和简单表单 gem,我想让用户能够从主页登录。我有输入,仅在 haml 中为它创建,并希望将它们用于此目的:

.login-wrapper
        .user-fields
          %input{type: "text", placeholder: "username", class: "ribbon-placeholder mail"}
          .slide
            %input{type: "password", placeholder: "password", class: "ribbon-placeholder password"}
            = link_to "#", class: "ribbon-button" do
              %span register
              .account-arrow
          .clearfix

        %input{type: "submit", value: "log in", class: "ribbon-button orange-background log-in"}
4

1 回答 1

1

好的,您可以使用这样的表格。这仅供参考,与您的形式不完全一样:-

<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
  <div><%= f.label :email %>
  <%= f.email_field :email, :autofocus => true %></div>

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

  <% if devise_mapping.rememberable? -%>
    <div>
        <label class="checkbox" for="merchant_remember_me">
            <%= f.check_box :remember_me %> Remember Me
        </label>
    </div>
  <% end -%>
<br />
  <div><%= f.submit "Sign in" %></div>
<% end %>
于 2013-09-04T12:38:40.360 回答