zoukankan      html  css  js  c++  java
  • 关于ruby重构的过程中去除不必要的format

     (文章是从我的个人主页上粘贴过来的,大家也可以访问我的主页 www.iwangzheng.com)

    #这段话可以由下面的话替代
    56     respond_to do |format|
    57       if @video.save
    58         format.html { redirect_to(:action => "index", :forminfo => @subject) }
    59       else
    60         format.html { render :action => "new" }
    61       end
    62     end
    63     #用于替代上面的方法
    64     if @video.save
    65       redirect_to(:action => "index", :forminfo => @subject)
    66     else
    67       render :action => "new"
    68     end

    #以下的方法可以由下面的方法替代
    102 respond_to do |format|
    103 format.html { redirect_to(:action => 'index', :forminfo => @subject) }
    104 format.xml { head :ok }
    105 end
    106 #用于替代上面的方法
    107 redirect_to(:action => 'index', :forminfo => @subject)

  • 相关阅读:
    操作系统简介
    正则表达式
    Python socket
    计算机网络基础
    计算机基础
    Python常用模块
    Python模块和包
    Python反射和内置方法(双下方法)
    Python类的成员
    更改命令行,完全显示hostname
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/3578076.html
Copyright © 2011-2022 走看看