11 - setting and retrieving cookies.rb
来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 20 行
RB
20 行
class ApplicationController < ActionController::Base before_filter :count_visits private def count_visits value = (cookies[:visits] || '0').to_i cookies[:visits] = (value + 1).to_s @visits = cookies[:visits] endend#---<!-- index.rhtml -->You've visited this website's pages <%= @visits %> time(s).#---cookies[:user_id] = { :value => '123', :expires => Time.now + 1.hour} #---cookies.delete :user_id#---
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?