Ruby on Rails 命令参考
1.1.Rails
1.1 创建一个Rails应用程序
$ rails app_name
可选项:
-d, database=xxx 指定安装一个数据库(mysql oracle postgresql sqlite2 sqlite3 ), 默认情况下是数据库
-r, ruby-path= 指定Ruby的安装路径,如果没有指定,scripts使用env去找Ruby
-f, freeze (冻结)freezes Rails在vendor/rails目录
1.2 API Documentation
$ gem_server
启动一个WEBrick服务器。这时候你可以通过Http://localhost:8808/ 打开浏览器去查看rails API文档
1.3 Rake
rake db:fixtures:load
# 载入fixtures到当前环境的数据库
# 载入指定的fixtures使用FIXTURES=x,y
rake db:migrate
# 迁移数据库通过在db/migrate目录下的脚本.可以指定版本号通过VERSION=x
rake db:schema:dump
# 创建一个db/schema.rb文件,通过AR能过够支持任何数据库去使用
rake db:schema:load
# 再入一个schema.rb文件进数据库
rake db:sessions:clear
# 清空sessions表
rake db:sessions:create
# 用CGI::Session::ActiveRecordStore创建一个sessions表为用户
rake db:structure:dump
# 导出数据库结构为一个SQL文件
rake db:test:clone
# 重新创建一个测试数据库从当前环境数据库中
rake db:test:clone_structure
# 重新创建测试数据库从开发模式数据库
rake db:test
repare
# 准备测试数据库并在入schema
rake db:test
urge
# 清空测试数据库
rake doc:app
# 创建HTML文件的API Documentation
rake doc:clobber_app
# 删除Documentation
rake doc:clobber_plugins
# 删除 plugin Documentation
rake doc:clobber_rails
# 删除Documentation
rake doc
lugins
# 产生Documation为所有安装的plugins
rake doc:rails
# 创建HTML文件的API Documentation
rake doc:reapp
# 强制重新创建HTML文件的API Documentation
rake doc:rerails
# 强制重新创建HTML文件的API Documentation
rake log:clear
# 清空目录log/下的所有日志文件
rake rails:freeze:edge
# Lock this application to latest Edge Rails. Lock a specific revision with REVISION=X
rake rails:freeze:gems
# Lock this application to the current gems (by unpacking them into vendor/rails)
rake rails:unfreeze
# Unlock this application from freeze of gems or edge and return to a fluid use of system gems
rake rails:update
# Update both scripts and public/javascripts from Rails
rake rails:update:javascripts
# Update your javascripts from your current rails install
rake rails:update:scripts
# Add new scripts to the application script/ directory
rake stats
# Report code statistics (KLOCs, etc) from the application
rake test
# Test all units and functionals
rake test:functionals
# Run tests for functionalsdb:test
repare
rake test:integration
# Run tests for integrationdb:test
repare
rake test
lugins
# Run tests for pluginsenvironment
rake test:recent
# Run tests for recentdb:test
repare
rake test:uncommitted
# Run tests for uncommitteddb:test
repare
rake test:units
# Run tests for unitsdb:test
repare
rake tmp:cache:clear
# 清空tmp/cache目录下的所有文件
rake tmp:clear
# 清空session, cache, 和socket文件从tmp/目录
rake tmp:create
# 为sessions, cache, and sockets创建tmp/目录
rake tmp:sessions:clear
# 清空所有在tmp/sessions目录下的文件
rake tmp:sockets:clear
# 清空所有在tmp/sessions 目录下的ruby_sess.* 文件
1.4 Scripts
script/about
# 输出当前环境信息
script/breakpointer
# 启动断点server
script/console
# 启动交换式的Rails控制台
script/destroy
# 删除通过generators创建的文件
script/generate
# -> generators
script/plugin
# -> Plugins
script/runner
# 执行一个任务在rails上下文中
script/server
# 启动开发模式服务器http://localhost:3000
//以下几个不知道怎么去使用
script/performance/profiler
script/performance/benchmarker
script/process/reaper
script/process/spawner
1.5 Generators
ruby script/generate model ModelName
ruby script/generate controller ListController show edit
ruby script/generate scaffold ModelName ControllerName
ruby script/generate migration AddNewTable
ruby script/generate plugin PluginName
ruby script/generate mailer Notification lost_password signup
ruby script/generate web_service ServiceName api_one api_two
ruby script/generate integration_test TestName
ruby script/generate session_migration
可选项:
-p, –pretend Run but do not make any changes.
-f, –force Overwrite files that already exist.
-s, –skip Skip files that already exist.
-q, –quiet Suppress normal output.
-t, –backtrace Debugging: show backtrace on errors.
-h, –help Show this help message.
-c, –svn Modify files with subversion. (Note: svn must be in path)
1.6 Plugins
script/plugin discover
# discover plugin repositories
script/plugin list
# list all available plugins
script/plugin install where
# install the a€wherea€? plugin
script/plugin install -x where
# install where plugin as SVN external
script/plugin install http://invisible.ch/projects/plugins/where
script/plugin update
# update installed plugins
script/plugin source
# add a source repository
script/plugin unsource
# removes a source repository
script/plugin sources
# lists source repositories
分享到:
相关推荐
搭建完完ruby on rails环境之后发现每次运行命令总会有这样一个Warning:DL is deprecated, please use Fiddle,例如: 对运行什么的没有影响,只是Dl过时了,可是Ruby大大不管这个问题,可是看着就烦呐~~ 解决方法...
使用 Vagrant 快速设置 Ruby on Rails 环境。 用法 安装 >= 1.2。 vagrant plugin install vagrant-berkshelf git clone git@github.com:1000k/rails_sandbox.git cp Vagrantfile.default Vagrantfile 编辑 ...
Ruby 3.0 Node.js 14或更高版本 配置[v0.25] 使用模板,并确保取消选中“包括所有分支” 将存储库克隆到本地计算机 使用git flow init所有本地计算机中的git-flow 集生产分公司: main 设置开发部门: development ...
这是一个基本的Ruby on Rails应用程序,用于对Rails应用程序中常见的任务进行练习和测试,以供开发人员参考。 该项目是部分完成的应用程序,其中包含以下记录的一些挑战,供开发人员实施。 先决条件 该项目假定您...
它可以快速生成Node.js和Ruby on Rails应用程序,并自动执行许多常见的开发任务。 特征 Shopify应用程序CLI通过以下方式帮助您的应用程序开发过程: 在创建一个应用 填充应用程序的测试数据,包括产品,客户和草拟...
一个项目模板,用于为AWS Lambda快速创建一个新的Rails应用程序。 细节: Ruby 2.7运行时上的Railsv6.x。 集成JavaScript开发。 使用LibSass&Webpacker编译CSS / JS资产。 没有ActiveRecord。 阅读我们的指南...
提交该存储库仅供参考,并且代码已大量重定基础,这将使提交变得不可能干净,但在开发新网站时是有用的参考。 使用以下提交消息符号: +添加^变化-删除项目结构Ansible Ansible脚本为服务器配置了在Dokku上运行Rails...
" description " : " Search for experts based on headings on their personal website " , " version " : " 0.1.0 " } 部署方式 要从本地计算机部署到生产环境,请从项目根目录运行以下命令: git push heroku ...
1.9.3 Starter Toolkit for DB2 on Rails.............................................................................17 1.9.4 Web 2.0 Starter Toolkit for DB2 ..............................................
1.9.3 Starter Toolkit for DB2 on Rails.............................................................................17 1.9.4 Web 2.0 Starter Toolkit for DB2 ..............................................