我在devise.rb
config.scoped_views = true
然后这是my app/views/users/sessions/new.html.erb
<div class="container">
<div id="login">
<%= devise_error_messages! %>
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<div class="login">
<li><%= f.label :email %> <%= f.text_field :email %></li>
<li><%= f.label :password %> <%= f.password_field :password %></li>
</div><!-- login -->
<div class="reset">
<%= f.input :email, :required => false, :autofocus => true %>
<%= f.input :password, :required => false %>
<%= f.input :remember_me, :as => :boolean if devise_mapping.rememberable? %>
</div>
<div class="login">
<%= f.button :submit, "Sign in" %>
</div>
<% end %>
<%= render "links" %>
</div><!-- login -->
</div><!-- container -->
当我提交它时,请返回页面。
当我禁用scoped.views
时,它会正常登录。
答案 0 :(得分:0)
我忘了你取消注释这一行
config.default_scope = :user