返回顶部

收藏

Call a Template File Directly

更多
Edit rubydev\double\app\controllers\goto_controller.rb

class HelloController < ApplicationController
  def there
    if Time.now.hour == 12
     render(:file => 'C:\here.rhtml')
    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

发表评论