4

我正在设计注册控制器覆盖,当我用新用户注册时,它第一次让我登录,但是当我退出然后尝试登录时,它在控制台下面给我一个错误

Processing by Devise::SessionsController#create as HTML
   Parameters: {"utf8"=>"✓","authenticity_token"=>"Wq8QW/F8X1BVxFcH6M9WU8OUpIGjKI1mKd1+/OBGyGY=", "user"=>  {"email"=>"jamil@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign   in"}
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`email` =   'jamil@gmail.com' LIMIT 1
 **Completed 401 Unauthorized in 16ms**
Processing by Devise::SessionsController#new as HTML
  Parameters: {"utf8"=>"✓" ,     "authenticity_token"=>"Wq8QW/F8X1BVxFcH6M9WU8OUpIGjKI1mKd1+/OBGyGY=", "user"=>     {"email"=>"jamil@gmail.com", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign     in"}

然后它给出无效电子邮件或密码的消息

请帮助我解决这个奇怪的问题...我挂了

这是我的注册表

<h2>Sign up</h2>
resource_name, :url => registration_path(resource_name)) 做 |f| %>
 <div><%= f.label :email %><br />
 <%= f.email_field :email, :autofocus => true %></div>

  <div><%= f.label :Connector_code %><br />
  <%= f.text_field :invitation_token,:value => @token %></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.label :Friends_code %><br />
  <%= f.text_field :friend_token ,:value =>params[:invitation_token]%></div>

  <div><%= f.submit "Sign up" %></div>
 <% end %>

<%= render "devise/shared/links" %>


Thanks 
4

1 回答 1

0

尝试在初始化文件或模型本身中显式设置 authentication_keys 参数:

# config/initializers/devise.rb
Devise.setup do |config|
   config.authentication_keys = [ :email ]
end

或者

# app/models/user.rb
class User < ActiveRecord::Base

  devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable, 
     :authentication_keys => [:email]

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me
end
于 2014-07-01T14:41:36.423 回答