B. Mac B. Mac - 5 months ago 45
Ruby Question

devise rails application redirecting to users/sign_in

all -
New to rails and web development. I started a new rails application and am using Devise. Whenever I hit Log In on the users/sign_in page, the page just refreshes.

Here is my terminal log after clicking Log In. It's showing the POST, I'm not sure why it's ultimately rendering devise/sessions/new.html....:

Started POST "/users/sign_in" for ::1 at 2017-10-02 09:19:20 -0400
Processing by Devise::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Ot4EJmxLvXrPpa6WYyqCXHxAUT3DcHimrIfw8HGyu5j7yuXvWArEkWzx59Dj3GZrlVDpgS/xSgXFSIt+mQqQnw==", "user"=>{"email"=>"bob@good.company", "password"=>"[FILTERED]"}, "commit"=>"Log in!"}
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = ? ORDER BY "users"."id" ASC LIMIT ? [["email", "bob@good.company"], ["LIMIT", 1]]
(0.1ms) begin transaction
(0.1ms) commit transaction
Completed 401 Unauthorized in 162ms (ActiveRecord: 0.3ms)

Started GET "/users/sign_in" for ::1 at 2017-10-02 09:19:21 -0400
Processing by Devise::SessionsController#new as HTML
Rendering devise/sessions/new.html.erb within layouts/application
Rendered devise/shared/_links.html.erb (1.2ms)
Rendered devise/sessions/new.html.erb within layouts/application (4.6ms)
Completed 200 OK in 45ms (Views: 43.5ms | ActiveRecord: 0.0ms)

My routes.rb

Rails.application.routes.draw do
get 'charges/create'
devise_for :users
get 'welcome/index'
get 'welcome/about'
resources :wikis
resources :charges, only: [:new, :create]

and my User.rb

class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable, :confirmable
has_many :wikis

before_save { self.email = email.downcase }

enum role: [:standard, :admin, :premium]
after_initialize { self.role ||= :standard }


Thank you for any direction and please let me know if I can provide any more details / code samples etc.

Answer Source

please update this user password from console

this happened because of you only provided only password attribute, you skipped password_confirmation attribute

eg User.where(email: "Youremail@email.com").update(password: "password", password_confirmation: "password")

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download