1.安装ruby 和 rails
$ rvm use ruby-2.3.0
$ gem install rails
$ rails --version
//run ruby
$ irb
$ cd workspace
$ rails new blog
$ rails server //localhost:3000
2.安装数据库
这里我用的是postgreSQL 4 (rail 自带的是mysql)
3.选择 heroku作为cloud platform as service(Paas) and Git
到heroku的官网注册并下载toolbelt(可以cli)
$ heroku login
$ cd myapp
$ heroku create
in config database.yml change
adapter: postgresql
database: myRubyBlog
username: postgres
password: 111111
pool: 5
timeout: 5000
IN GEMFILE
ADD gem ‘pg‘ and comment gem ‘sql....‘
$ gem install pg
$ bundle install
4. create controller (s)
rails g controller home index
rails g controller posts
在app/controller和app/view 以及config/routers 更改变量
5 create model (single)
$ rails g model category name:string
$rake db:migrate //create table
$ rails g model post title:string body:text category_id:integer author_id:integer
then you can find the table in datebase