返回顶部

收藏

Creating a View

更多
// To creates the web application
// Use the command rails applicationName: 
rails java2s

//Use the Ruby command ruby script/generate controller Hello:

ruby script/generate controller Hello

//Creating an Action
//Edit hello_controller.rb under java2s\app\controllers

class HelloController < ApplicationController
  def there
  end
end

//To establish a view template for the hello controller's there action, 
//you can create a file named there.rhtml and store it in the 
//java2s\app\views\hello directory.

<html>
  <head>
    <title>Using Ruby on Rails</title>
  </head>
  <body>
    <h1>Welcome to Ruby on Rails</h1>
    This is your first Ruby on Rails application.
    <br>
    <br>
    Using this application, you've been introduced to
    controllers, actions, and views.
    <br>
    <br>
    Not bad for a first example!
  </body>
</html>

// To launch your new application:
cd java2s
ruby script/server

// In Rails, you create an action by adding a method to a controller, 
// You can reach this new action by navigating to http://localhost:3000/hello/there

标签:Ruby,Rails

收藏

0人收藏

支持

0

反对

0

»更多 您可能感兴趣的代码
  1. 2016-04-23 18:50:43Link to an Action by 杨洋
  2. 2016-08-20 16:27:54Mix Ruby Code and HTML by digua
  3. 2016-10-13 09:29:34Read Data from a Checkbox by digua
  4. 2016-01-10 21:40:25Passing Data from an Action to a View by 胡晋
  5. 2016-08-20 16:38:38A loop executes the body of the loop by zetaliang
  6. 2016-08-20 16:54:59Escaping Sensitive Text by zetaliang
  7. 2016-10-10 09:35:27Initialize Data in an HTML Control by 永明
  8. 2016-08-20 17:12:28Tie a Text Field to a Model by JustForFly
  9. 2016-03-06 20:22:08Use cookie by digua
  10. 2016-03-21 10:38:51Call a Template File Directly by JustForFly
  11. 2019-06-17 21:18:10PHP+jQuery.photoClip.js图片裁剪上传实例 by 素材火官网

发表评论