rails常见命令

Rake命令

bundle exec rake -T 查看全部的Rake任务
bundle exec rake -T db 查看全部db命名空间的任务
bundle exec rake db:migrate
bundle exec rake db:rollback
bundle exec rake db:migrate VERSION=0
bundle exec rake db:create:all 根据database.yml文件建立好develop、test库,若是已存在,提示已存在
bundle exec rake db:test:clone 将develop数据库结构克隆到test库
bundle exec rake rspec
bundle exec rake assets:precompile RAILS_ENV=production
bundle exec rake notes:custom ANNOTATION=TODO

Generate命令

rails g(enerate) scaffold User name:string email:string --no-test-framework
rails g(enerate) controller StaticPages home help --no-test-framework
rails g(enerate) model Foo bar:string baz:integer
rails generate rspec:install 生成RSpec配置文件(.rspec),用来存放测试文件的文件夹(spec),以及一个存储帮助函数的文件(spec/spec_helper.rb)

Destroy命令

rails d(estory) scaffold User
rails d(estory) controller StaticPages home help
rails d(estory) model Foo

New命令

rails new sample_app --skip-test-unit
相关文章
相关标签/搜索