2017-03-01 103 views
1

我已經設置了Devise其他時間。但由於某種原因,這次我無法登錄。我用http://prelang.com/配置了我的應用程序。設計未登錄

這是我的路線:

devise_for :users, controllers: {registrations: "users/registrations", sessions: "users/sessions", passwords: "users/passwords"} 
    devise_for :admin_users, ActiveAdmin::Devise.config 
    ActiveAdmin.routes(self) 

#->Prelang (user_login:devise/stylized_paths) 
    devise_scope :user do 
    get "login" => "users/sessions#new",   as: :new_user_session 
    post "login" => "users/sessions#create",  as: :user_session 
    delete "signout" => "users/sessions#destroy",  as: :destroy_user_session 

    get "signup" => "users/registrations#new", as: :new_user_registration 
    post "signup" => "users/registrations#create", as: :user_registration 
    put "signup" => "users/registrations#update", as: :update_user_registration 
    get "account" => "users/registrations#edit", as: :edit_user_registration 
    end 

而且我登入查看sessions/new.html.slim

= simple_form_for(resource, as: resource_name, url: session_path(resource_name), html: {id: "loginForm"}) do |f| 
    .form-group 
    = f.input :email, as: :string, label: "Correo electrónico", placeholder: "[email protected]", required: true, autofocus: true, class: "form-control", id: "username" 
    .form-group 
    = f.input :password, label: "Contraseña", placeholder: "*******", required: false, autofocus: true, class: "form-control", id: "password" 

    = f.submit "Iniciar sesión", class: "btn btn-success btn-block" 
    = link_to "Registrarte", new_user_registration_path, class: "btn btn-default btn-block" 

,我試圖用已通過註冊創建簽到用戶。這是用戶的物體是怎樣的:

#<User id: 3, email: "[email protected]", 
created_at: "2017-03-01 11:21:47", 
updated_at: "2017-03-01 11:21:47", 
username: nil> 

我得到的是閃光報警Invalid Login or password.。如果我看一看在PARAMS被傳遞到SessionsControllernew行動),這是它的樣子:

{"utf8"=>"✓", 
"authenticity_token"=>"9jQjU5BuFDJJRdJuPZVvHHzz3R3t16H+Jh46O4w3KPU=", 
"user"=>{"email"=>"[email protected]", "password"=>"holahola"}, 
"commit"=>"Iniciar sesión", 
"action"=>"create", 
"controller"=>"users/sessions"} 

我怎樣才能使它發揮作用? 在此先感謝。

+0

你的'params email'和用戶表'記錄電子郵件'看起來不一樣 – ashvin

+0

@ashvin謝謝指出。信息是錯誤的。我用正確的數據庫記錄更新了它。 – borjagvo

+0

你的表單作爲發佈請求提交?因爲簡單的形式提交爲get。 –

回答

0

事實證明,Preflang使用電子郵件或用戶名登錄。而不是命名會話/ new.hmtl.slim輸入法識別用戶爲:email我不得不稱之爲:login。現在它可以工作。

該方法描述爲here