📄 10 - setting and retrieving session information.rb
字号:
class IndexController < ApplicationController def index session[:first_time] ||= Time.now endend#---<!-- index.rhtml -->You first visited this site on <%= session[:first_time] %>. That was <%= time_ago_in_words session[:first_time] %> ago.#---class ApplicationController < ActionController::Base model :user, :ticket, :item, :historyend#---class IndexController < ApplicationController def index session[:user] ||= User.find(params[:id]) endend#---class ApplicationController < ActionController::Base session :offend#---class MyController < ApplicationController session :offend#---class MyController < ApplicationController session :off, :only => ['index'] def index #This action will not have any sessions available to it endend#--- flash[:error] = 'Invalid login.'#---Rails::Initializer.run do |config| config.action_controller.session_store = :active_record_storeend#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -