Rails sessions not saving

后端 未结 3 1968
死守一世寂寞
死守一世寂寞 2021-01-20 02:14

I\'m in the process of upgrading a Rails app from Rails 2 directly to Rails 4. I\'m using the new /config/initializers/session_store.rb file, with CookieStore

3条回答
  •  庸人自扰
    2021-01-20 02:34

    From: Railscasts Episode 415 Upgrading to Rails 4

    There’s one more configuration change we need to make, in the secret token initializer. In Rails 4 the configuration option in this file has been renamed from secret_token to secret_key_base. We’ll need to specify both options while we’re transitioning from Rails 3 but once we’ve successfully migrated our application we can remove the secret_token option. It’s best to use a different token for our secret_key_base.

    This is necessary because we’re moving from a serialized cookie stored on the client to an encrypted cookie. This prevents users from easily being able to see the contents of their session cookies.

    The episode includes a very good series of tips regarding upgrading from 2 to 4 and I was able to do that successfully using this tutorial.

提交回复
热议问题