samedi 29 avril 2017

DEVISE sign in not working

Hi I'm very new to rails so I'm not sure what I'm doing wrong. I'm working on an app and have implemented very basic devise. The console output indicates that it should move on to the the page in the path when a sign is complete but it is never getting passed the sign in page.

User.rb

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
  has_many :sessions, dependent: :destroy
  has_many :session2s, dependent: :destroy
end

routes.rb

Rails.application.routes.draw do
# resources :users
devise_for :users
resources :sessions do 
  resources :session2s 
end
# The priority is based upon order of creation: first created -> highest    priority.
# See how all your routes lay out with "rake routes".

# You can have the root of your site routed with "root"
root 'application#index'
get '/welcome'=>'application#index'
post'/sessions/user'=>'sessions#new'

rake routes

new_user_session GET    /users/sign_in(.:format)                           devise/sessions#new
        user_session POST   /users/sign_in(.:format)                           devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format)                          devise/sessions#destroy
   new_user_password GET    /users/password/new(.:format)                      devise/passwords#new
  edit_user_password GET    /users/password/edit(.:format)                     devise/passwords#edit
       user_password PATCH  /users/password(.:format)                          devise/passwords#update
                     PUT    /users/password(.:format)                          devise/passwords#update
                     POST   /users/password(.:format)                          devise/passwords#create
cancel_user_registration GET    /users/cancel(.:format)                            devise/registrations#cancel
   new_user_registration GET    /users/sign_up(.:format)                           devise/registrations#new
   edit_user_registration GET    /users/edit(.:format)                              devise/registrations#edit
       user_registration PATCH  /users(.:format)                                   devise/registrations#update
                         PUT    /users(.:format)                                   devise/registrations#update
                         DELETE /users(.:format)                                   devise/registrations#destroy
                     POST   /users(.:format)                                   devise/registrations#create
   session_session2s GET    /sessions/:session_id/session2s(.:format)          session2s#index
                     POST   /sessions/:session_id/session2s(.:format)          session2s#create
new_session_session2 GET    /sessions/:session_id/session2s/new(.:format)      session2s#new
   edit_session_session2 GET    /sessions/:session_id/session2s/:id/edit(.:format) session2s#edit
        session_session2 GET    /sessions/:session_id/session2s/:id(.:format)      session2s#show
                     PATCH  /sessions/:session_id/session2s/:id(.:format)      session2s#update
                     PUT    /sessions/:session_id/session2s/:id(.:format)      session2s#update
                     DELETE /sessions/:session_id/session2s/:id(.:format)      session2s#destroy
            sessions GET    /sessions(.:format)                                sessions#index
                     POST   /sessions(.:format)                                sessions#create
new_session GET    /sessions/new(.:format)                            sessions#new
        edit_session GET    /sessions/:id/edit(.:format)                       sessions#edit
             session GET    /sessions/:id(.:format)                            sessions#show
                     PATCH  /sessions/:id(.:format)                            sessions#update
                     PUT    /sessions/:id(.:format)                            sessions#update
                     DELETE /sessions/:id(.:format)                            sessions#destroy
                root GET    /                                                  application#index
             welcome GET    /welcome(.:format)                                 application#index
       sessions_user POST   /sessions/user(.:format)                           sessions#new

console messages

Started POST "/sessions/user" for 107.15.244.73 at 2017-04-30 03:24:53 +0000
Cannot render console from 107.15.244.73! Allowed networks: 127.0.0.1, ::1,    127.0.0.0/127.255.255.255
Processing by SessionsController#new as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"A8ZTEKOg+86FHiL7HMUo69Cz+0OmYiedg92Nci3D/ZhWwK1W1WN7weI/gZtq9Qc0yC1igj/ZpPwtLm6YkJhY9Q==", "user"=>{"email"=>"z@g", "password"=>"[FILTERED]", "remember_me"=>"1"}, "commit"=>"Log in"}
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)


Started GET "/users/sign_in" for 107.15.244.73 at 2017-04-30 03:24:53 +0000
Cannot render console from 107.15.244.73! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Devise::SessionsController#new as HTML
Rendering devise/sessions/new.html.erb within layouts/application
Rendered devise/shared/_links.html.erb (1.1ms)
Rendered devise/sessions/new.html.erb within layouts/application (4.2ms)
Completed 200 OK in 26ms (Views: 25.1ms | ActiveRecord: 0.0ms)

I just created the username and password in signup and the logs show its definitely entered into the table so I'm not sure what's happening. I see the 401 error but all the previous questions on this topic have more complicated devise methods so I'm not sure whats going and help on getting a functioning sign in page would be great ! Thanks!

Aucun commentaire:

Enregistrer un commentaire