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)

  • 相关阅读:
    Hibernate核心接口和类
    Struts 2基础知识
    博客开篇
    程序员的幽默笑话(深意爆笑)
    追MM的各种算法
    全局css(慕课)
    全局css
    目录的分层
    class 设置多个css属性
    Python爬虫学习:四、headers和data的获取
  • 原文地址:https://www.cnblogs.com/iwangzheng/p/3578076.html
Copyright © 2011-2022 走看看