ユーザーの新規登録をしようとするとActionController::InvalidAuthenticityToken in UsersController#create
とエラーが出てしまいます
new.html.erb
<%= form_tag("users/create", method: :post) do %> <input name = "name"> <input name = "email"> <input type = "password" name = "password"> <input type="submit" value="サインイン"> <% end %>
users_controller.rb
class UsersController < ApplicationController def new end def create @user = User.new(name: params[:name], email: params[:email], password: params[:password]) @user.save redirect_to("/") end end
routes.rb
Rails.application.routes.draw do get 'signup' => "users#new" post "users/create" => "users#create" get "users/destroy" => "users#destroy" get "login" => "users#login_form" post "logout" => "users#logout" resources :posts root 'welcome#index' # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end
エラー文 ActionController::InvalidAuthenticityToken in UsersController#create ActionController::InvalidAuthenticityToken Extracted source (around line #211): def handle_unverified_request raise ActionController::InvalidAuthenticityToken end end end
createアクションに問題があることぐらいしかわかりません(T ^ T)
似たような質問を探してみたのですが、答えが見つからず悪戦苦闘しています
誰か助けてください><
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/12 11:55