2017-12-13 15 views
0

私は、新しいレールのプロジェクトに取り組んで、私の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 

に起こっているが、これは私のアプリケーショントレース

http://localhost:3000

ありません。

[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 
+0

エラースタックトレースを投稿できますか? –

+0

'skip_before_action:verify_authenticity_token'この行をあなたの' protect_from_forgery with::exception'の隣に追加してください。 – Gabbar

+0

@Gabbarもし彼がそうしたら、protect_from_forgeryを保存する点は何ですか... まず、あなたのエラーは何ですか? http:// localhost:3000/pages/home にあると言いますが、偽造チェックはGET以外のアクションでのみ発生し、GETリクエストのように表示されます。 – nekogami

答えて

0

protect_from_forgeryがレール保護する機能です他のユーザーによる不正な攻撃。したがって、このエラーが発生した場合は、そのページで認証しようとしていることを意味します。 skip_before_action :verify_authenticity_tokenを追加してスキップすることができます。

+0

Thx私は今夜これを行おうとします – westman2222

+0

私は今このエラーが表示されています:ヘルパーファイルヘルパーが見つかりません/ c:/sites/cookies/app/helpers/application_helper.rb_helper.rb – westman2222

関連する問題