【rails3教材】博客构建过程

构建rails项目--blog

$ rails new blog --skip-bundle
$ cd blog
$ bundle --local
$ bundle install #安装需要的包
$ rake db:create #创建数据库
$ rails s #启动服务器

  

Hello Rails

$ rails g controller home index

修改app/views/home/index.html.erb文件内容

<h1>Hello, Rails</h1>

如果有删除public/index.html

修改config/routes.rb(应用程序路由设置)

Blog::Application.routes.draw do  
    root :to => 'home#index'  #:to指定了需要访问的控制器与动作  
end

现在可以http://localhost:3000看到Hello Rails

原文地址:https://www.cnblogs.com/lizunicon/p/3527591.html