2013-06-13 152 views
4

我正在設計註冊控制器覆蓋,當我註冊一個新用戶時,它第一次登錄我,但是當我退出然後嘗試簽名在它給了我下面的控制檯已完成401註冊後未授權的用戶登錄

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

的錯誤,然後它給了無效的電子郵件或密碼的消息

請幫我在這個奇怪的問題...我掛了

這裏是我的註冊表格

<h2>Sign up</h2> 
resource_name,:url => registration_path(resource_name))do | 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 
+0

你能後的新會員註冊登記表 – David

+0

雅,編輯上面的問題 –

+0

當然,你錯過了<%= form_for(resource,:as =>'這意外地在你的表單頂部? – David

回答

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 
相關問題