では動作しません、私はhttps://myapp.com/users/sign_inの「サインイン」ボタンを押した後、次のエラーが表示されます。工夫は、HTTPS
ActionController::InvalidAuthenticityToken in Devise::SessionsController#create
を関係なく、既存のユーザーの資格情報の。
http://myapp.com/users/sign_inにログインするためにボタンを押した場合、ユーザーはサインインしてアプリケーションがスムーズに動作しているように見えますが、ユーザーはHTTPでも投稿を作成することができます。
私はSSLでの認証作業をしたいと思っています。
routes.rbを:
devise_for :users
application_controller.rb:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
user.rb:
class User < ApplicationRecord
devise :database_authenticatable, :recoverable, :rememberable, :registerable, :trackable, :validatable
end
- 私は頭の中で
<%= csrf_meta_tags %>
を持って - は、私は私は私がルートに
devise_for :users, :controllers => { :sessions => "users/sessions" }
を試してみました - 新しいセッションのために
form_for
で<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
を入れてみました - アプリ/コントローラ/ application_controller.rbに
protect_from_forgery with: :null_session
代わりのprotect_from_forgery with: :exception
を試してみました - のブラウザでCookieをクリア
私は、設定/環境/ production.rb
に
config.to_prepare { Devise::SessionsController.force_ssl }
config.to_prepare { Devise::RegistrationsController.force_ssl }
config.to_prepare { Devise::PasswordsController.force_ssl }
を追加しようとしました
これはあなたの問題http://stackoverflow.com/questions/38331496/rails-5-actioncontrollerinvalidauthenticitytoken-error – bunty
@buntyを解決しますであってもよいし、まあ、それはしませんでした –
this https://github.com/plataformatec/devise/wiki/How-To:-User-SSL-(HTTPS) – bunty