04 - displaying templates with render.rb

来自「O Reilly Ruby Cookbook source code」· RB 代码 · 共 53 行

RB
53
字号
class ListController < ApplicationController  def index    @list = ['papaya', 'polio vaccine']    render :action => 'shopping_list'  end  def shopping_list    @list = ['cotton balls', 'amino acids', 'pie']  endend#---class ListController < ApplicationController  def index    render :action => 'shopping_list'    @budget = 87.50  end  def shopping_list    @list = ['lizard food', 'baking soda']  endend#---class ListController < ApplicationController  def index    shopping_list and render :action => 'shopping_list'    @budget = 87.50  endend#---class ListController < ApplicationController  def plain_and_fancy    render :action => 'plain_list'    render :action => 'fancy_list'  end#---class ListController < ApplicationController  def plain_or_fancy    if params[:fancy]      render :action => 'fancy_list'    else      render :action => 'plain_list'    end  endend#---class ListController < ApplicationController  def index    render :action => 'shopping_list' and return    @budget = 87.50         # This line won't be run.  endend#---

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?