Active Record 数据迁移

1.创建controler: welcome ;action: index

$ rails generate controller welcome index

2.创建名为Article的model定义title:string text:text
$ bin/rails generate model Article title:string text:text 
$ bin/rake db:migrate 迁移数据

3.创建model 添加关联
$ rails generate model Comment commenter:string body:text article:references

4.在文件中 config/routes.rb 添加一个rest 动作
Rails.application.routes.draw do
resources :articles
end

$ bin/rake routes

5.进入控制台
rails c

posted @ 2016-02-14 17:32  上官帅帅  阅读(237)  评论(0编辑  收藏  举报