私は、新しいレールのプロジェクトに取り組んで、私のlocalhostの開発環境でこのエラーが発生して右バットオフいくつかの問題を抱えています:protect_from_forgery:例外レール5
protect_from_forgery with: :exception
私のアプリケーションヘルパーファイル:
をclass ApplicationController < ActionController::Base
protect_from_forgery with: :exception
end
私はどのようにこのエラーを回避し解決できますか?
注意すべきことは、これは
http://localhost:3000/pages/home
に起こっているが、これは私のアプリケーショントレース
ありません。
[email protected] /c/sites/cookies (master)
$ rails --trace
** Invoke default (first_time)
** Invoke test (first_time)
** Execute test
** Execute default
Run options: --seed 1992
# Running:
E
Error:
PagesControllerTest#test_should_get_home:
AbstractController::Helpers::MissingHelperError: Missing helper file helpers/c:/sites/cookies/app/helpers/application_helper.rb_helper.rb
app/controllers/application_controller.rb:1:in `<top (required)>'
app/controllers/pages_controller.rb:1:in `<top (required)>'
test/controllers/pages_controller_test.rb:5:in `block in <class:PagesControllerTest>'
bin/rails test test/controllers/pages_controller_test.rb:4
Finished in 1.552152s, 0.6443 runs/s, 0.0000 assertions/s.
1 runs, 0 assertions, 0 failures, 1 errors, 0 skips
エラースタックトレースを投稿できますか? –
'skip_before_action:verify_authenticity_token'この行をあなたの' protect_from_forgery with::exception'の隣に追加してください。 – Gabbar
@Gabbarもし彼がそうしたら、protect_from_forgeryを保存する点は何ですか... まず、あなたのエラーは何ですか? http:// localhost:3000/pages/home にあると言いますが、偽造チェックはGET以外のアクションでのみ発生し、GETリクエストのように表示されます。 – nekogami