返回顶部

收藏

Selecting Which View to Render

更多
class HelloController < ApplicationController
  def there
     if Time.now.hour == 12
      render(:action => :here)
     end
  end

  def here

  end

end

// File: app\views\hello\there.rhtml:
 <html>
   <head>
     <title>Using Two Views</title>
   </head>
   <body>
     there
   </body>
 </html>

//File: app\views\hello\here.rhtml:
 <html>
   <head>
     <title>Using Two Views</title>
   </head>
   <body>
     here
   </body>
 </html>

 Start server: ruby script/server 
 Navigate to http://localhost:3000/hello/there
 Now navigate to http://localhost:3000/hello/here 

标签:Ruby,Rails

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-01-10 11:10:50Reading Data from Select Controls by 胡晋
  2. 2016-08-20 16:08:51Display random image by LeoSun
  3. 2016-04-23 18:50:43Link to an Action by 杨洋
  4. 2016-08-20 16:27:54Mix Ruby Code and HTML by digua
  5. 2016-10-13 09:29:34Read Data from a Checkbox by digua
  6. 2016-01-10 21:40:25Passing Data from an Action to a View by 胡晋
  7. 2016-08-20 16:38:38A loop executes the body of the loop by zetaliang
  8. 2016-08-20 16:54:59Escaping Sensitive Text by zetaliang
  9. 2016-10-10 09:35:27Initialize Data in an HTML Control by 永明
  10. 2016-08-20 17:12:28Tie a Text Field to a Model by JustForFly
  11. 2016-03-06 20:22:08Use cookie by digua
相关聚客文章
  1. Peter Cooper 发表 2012-11-09 18:32:48 This Week in Ruby: Rubinius 2.0-rc1, Rake 10, Refa
  2. 周亮 发表 2012-07-22 16:49:01 [Rails代码解读]ActiveSupport::Concern
  3. TREE 发表 2013-06-13 14:18:03 接触Ruby on Rails一个月
  4. tianji_2013 发表 2013-07-12 02:54:39 (北京)天际网补招 3 名 Rails/Ruby 工程师
  5. siko 发表 2013-07-27 03:24:39 [上海]Ruby/Rails 开发工程师
  6. 木易小伟 发表 2012-04-11 10:05:58 How to Set Up Ruby Environment With RVM on Ubuntu
  7. timfarther 发表 2014-04-08 02:15:29 ruby on rails 笔记~
  8. 博主 发表 2014-03-30 03:11:37 How to Install Ruby on Rails on CentOS 6.5 Using R
  9. wxianfeng 发表 2013-05-12 07:47:59 Rails源码 attr_internal
  10. 博主 发表 2012-07-11 07:30:00 开始学习 Ruby on Rails
  11. 博主 发表 2014-09-28 00:00:00 Ruby on Rails的Gem包
  12. 博主 发表 2013-06-23 19:39:00 在Mac OS X下安装Ruby on Rails

发表评论