當我使用rails new my_api --api
創建rails api時,它會生成一個rails應用程序,該應用程序默認配置爲將會話數據存儲在cookie中(可以在config/initializers/session_store.rb
中看到),即使休息api不一定與瀏覽器客戶端進行交談。爲什麼配置Rails API應用程序默認將會話數據存儲在cookie中?
我在這裏錯過了什麼嗎?
當我使用rails new my_api --api
創建rails api時,它會生成一個rails應用程序,該應用程序默認配置爲將會話數據存儲在cookie中(可以在config/initializers/session_store.rb
中看到),即使休息api不一定與瀏覽器客戶端進行交談。爲什麼配置Rails API應用程序默認將會話數據存儲在cookie中?
我在這裏錯過了什麼嗎?
此前,默認SessionStore
是ActiveRecord::SessionStore
。在Rails 4.0.0又改爲CookieStore
和ActiveRecord::SessionStore
被分解出來成爲一個獨立的寶石:
ActiveRecord::SessionStore is extracted out of Rails into a gem activerecord-session_store. Setting config.session_store to :active_record_store will no longer work and will break if the activerecord-session_store gem isn't available.
椐:
https://github.com/rails/activerecord-session_store
的變化是在Rails的4.0.0更新日誌記錄此承諾:
https://github.com/rails/rails/commit/0ffe19056c8e8b2f9ae9d487b896cad2ce9387ad
各種博客有評論Ø面向性能的變化,Rails 4包含了許多其他的特性,這些特性被分解爲不同的寶石。這並不意味着你不應該使用它們,它只是不被認爲是核心框架所需要的。