0
我有一個控制器,可以根據該控制器創建一個包含我正在開發的遊戲信息的cookie。我遇到的問題是,當我在該控制器中使用另一個操作時,值發生了變化。檢查簽名cookie是否存在
這是我的控制器:
def new
@videos = Video.order("RANDOM()").limit(2)
if !cookies.signed[:game]
cookies.signed[:game] = {
:value => @videos,
:domain => 'localhost',
:secure => !(Rails.env.test? || Rails.env.development?)
}
end
end
def start_game
respond_to do |format|
format.js
end
end
start_game.erb.js
console.log('<%= cookies.signed[:game].first.titel %>') # This should print out the same value but it doesn't do that.
new.html.erb
...
<%= button_to "game", { :action => "start_game" }, { :remote => true, :form_class => "test_button" } %>
我可以檢查whetever簽署的cookie存在與否?