[ruby on rails] ActiveRecordにセッションを格納するようにしたらエラー

セッションストアにActiveRecordを使用するには、environment.rbで以下の箇所のコメントを外す。

  config.action_controller.session_store = :active_record_store
セッション格納用のテーブルは、
rake db:sessions:create
rake db:migrate
で作成。

セッションストアにActiveRecordを使用するようにしたら、以下のエラーが発生。

No :secret given to the #protect_from_forgery call. Set that or use a session store capable of generating its own keys (Cookie Session Store).

application.rbで以下の箇所の:secretのコメントを外したら解決。

  # See ActionController::RequestForgeryProtection for details
  # Uncomment the :secret if you're not using the cookie session store
  protect_from_forgery # :secret => '7136b0968f24e7318da7eb62e50d05b7'

active_record_store sessions does not pass a :secret to #protect_from_forgery in Rails 2.0.0 Preview - Ruby Forum

トラックバック(0)

このブログ記事を参照しているブログ一覧: ActiveRecordにセッションを格納するようにしたらエラー

このブログ記事に対するトラックバックURL: http://www.pistolfly.jp/mt/mt-tb-alt.cgi/274

コメントする