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被传递到SessionsController
(new
行动),这是它的样子:
{"utf8"=>"✓",
"authenticity_token"=>"9jQjU5BuFDJJRdJuPZVvHHzz3R3t16H+Jh46O4w3KPU=",
"user"=>{"email"=>"[email protected]", "password"=>"holahola"},
"commit"=>"Iniciar sesión",
"action"=>"create",
"controller"=>"users/sessions"}
我怎样才能使它发挥作用? 在此先感谢。
你的'params email'和用户表'记录电子邮件'看起来不一样 – ashvin
@ashvin谢谢指出。信息是错误的。我用正确的数据库记录更新了它。 – borjagvo
你的表单作为发布请求提交?因为简单的形式提交为get。 –