新建一个rails工程 
$ rails new + 工程名 
进入控制台 
$ rails c 或者 rails console 
开启服务 
$ rails server -p *** 

生成Rails API文档

$ rake doc:rails #/doc/api目录下就有了一份完整的Rails API文档
操作数据库 
$ sudo rails dbconsole 我用的是ubuntu,需要sudo,要不然权限有问题 

通过rails的scaffold脚手架生成一个简易web  CRUD程序,包括一组ModelViewsController
$ rails g scaffold person name:string bio:text birthday:date


创建一个model 
$ rails g model article 
删除这个创建的model 
$ rails destroy model article

创建一个controller

$ rails g controller products index   #创建一个controller 顺带创建了index.html.erb

创建数据库(指定环境需要加上:  RAILS_EVN=product)

$ rake db:create  #根据config/database.yml中的配置创建各环境下的空数据库

$ rake db:migrate  #根据app的migration 文件生成对应的表

安装plugin

$ rails plugin install  https://..../..git     #对应的plugin会被安装到 Vendor目录下

相关文章:

  • 2022-03-10
  • 2022-12-23
  • 2021-08-16
  • 2021-07-31
  • 2021-07-17
  • 2022-12-23
  • 2021-12-07
猜你喜欢
  • 2021-09-13
  • 2021-09-24
  • 2021-05-22
  • 2022-01-18
  • 2021-12-11
  • 2022-12-23
  • 2021-10-23
相关资源
相似解决方案