###前提・実現したいこと
deviseでログインをしたところ、エラーも出さずログインできずにそのままログイン画面に止まってしまいます。rails cでユーザーが保存されていることも確認しましたが、何も問題ありません。
ログインボタンを押したときのログも確認しましたが、特にエラーも見当たりませんでした。
ログインできるようにするにはどうしたらよろしいでしょうか?
###該当のソースコード
ActiveRecord::Schema.define(version: 20170707154233) do create_table "users", force: :cascade do |t| t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.string "confirmation_token" t.datetime "confirmed_at" t.datetime "confirmation_sent_at" t.string "unconfirmed_email" t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "name", default: "", null: false t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end end
sessions.html.erb
<div class="row"> <div class="col-lg-8"> <div class="bs-component"> <form> <fieldset> <legend>Sign in</legend> <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> <div class="form-group"> <label for="exampleInputEmail1"><%= f.label :email %></label> <div aria-describedby="emailHelp" placeholder="Enter email"> <%= f.email_field :email, autofocus: true, class: "form-control", id: "exampleInputEmail1" %> </div> </div> <div class="form-group"> <label for="exampleInputPassword1"><%= f.label :password %></label> <div placeholder="Password"> <%= f.password_field :password, autocomplete: "off", class: "form-control", id: "exampleInputPassword1" %> </div> </div> <% if devise_mapping.rememberable? -%> <div class="form-group"> <%= f.check_box :remember_me %> <%= f.label :remember_me %> </div> <% end -%> <div class="actions"> <%= f.submit "Log in", class: "btn btn-primary" %> </div> <% end %> </fieldset> </form> </div> </div> </div> <%= render "devise/shared/links" %>
seeds/users.rb
names = %w(Kyouko,,,,) 0.upto(9) do |x| user = User.create( name: names[x], email: "#{names[x]}@example.com", password: "password", password_confirmation: "password" ) user.skip_confirmation! user.save! end
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, :confirmable validates :name, presence: true, length: { maximum: 50 } end
routes.rb
Rails.application.routes.draw do devise_for :users root to: "top#index" get "about" => "top#about", as: "about" resources :users, only: [:index, :show] end
###試したこと
こちらを参考にしています。
###補足情報(言語/FW/ツール等のバージョンなど)
Rails 5.0.4
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。