RAILS

1.1 创建Rails应用程序

$rails[_VERSION_]app_name可选项:
VERSION: 指定rails的版本(如果安装了多个rails版本),VERSION前后各加一下划线, 如"_1.2.6_"

-d,database=xxx指定安装一个数据库(mysqloraclepostgresqlsqlite2sqlite3),默认情况下是数据库

-r,ruby-path=指定Ruby的安装路径,如果没有指定,scripts使用env去找Ruby

-f,freeze(冻结)freezesRails在vendor/rails目录

1.2APIDocumentation

$gem_server

启动一个WEBrick服务器。这时候你可以通过Http://localhost:8808/打开浏览器去查看railsAPI文档

1.3Rake

rakedb:fixtures:load

#载入fixtures到当前环境的数据库

#载入指定的fixtures使用FIXTURES=x,y

rakedb:migrate

#迁移数据库通过在db/migrate目录下的脚本.可以指定版本号通过VERSION=x

rakedb:schema:dump

#创建一个db/schema.rb文件,通过AR能过够支持任何数据库去使用

rakedb:schema:load

#再入一个schema.rb文件进数据库

rakedb:sessions:clear

#清空sessions表

rakedb:sessions:create

#用CGI::Session::ActiveRecordStore创建一个sessions表为用户

rakedb:structure:dump

#导出数据库结构为一个SQL文件

rakedb:test:clone

#重新创建一个测试数据库从当前环境数据库中

rakedb:test:clone_structure

#重新创建测试数据库从开发模式数据库

rakedb:test:prepare

#准备测试数据库并在入schema

rakedb:test:purge

#清空测试数据库

rakedoc:app

#创建HTML文件的APIDocumentation

rakedoc:clobber_app

#删除Documentation

rakedoc:clobber_plugins

#删除pluginDocumentation

rakedoc:clobber_rails

#删除Documentation

rakedoc:plugins

#产生Documation为所有安装的plugins

rakedoc:rails

#创建HTML文件的APIDocumentation

rakedoc:reapp

#强制重新创建HTML文件的APIDocumentation

rakedoc:rerails

#强制重新创建HTML文件的APIDocumentation

rakelog:clear

#清空目录log/下的所有日志文件

rakerails:freeze:edge

#LockthisapplicationtolatestEdgeRails.LockaspecificrevisionwithREVISION=X

rakerails:freeze:gems

#Lockthisapplicationtothecurrentgems(byunpackingthemintovendor/rails)

rakerails:unfreeze

#Unlockthisapplicationfromfreezeofgemsoredgeandreturntoafluiduseofsystemgems

rakerails:update

#Updatebothscriptsandpublic/javascriptsfromRails

rakerails:update:javascripts

#Updateyourjavascriptsfromyourcurrentrailsinstall

rakerails:update:scripts

#Addnewscriptstotheapplicationscript/directory

rakestats

#Reportcodestatistics(KLOCs,etc)fromtheapplication

raketest

#Testallunitsandfunctionals

raketest:functionals

#Runtestsforfunctionalsdb:test:prepare

raketest:integration

#Runtestsforintegrationdb:test:prepare

raketest:plugins

#Runtestsforpluginsenvironment

raketest:recent

#Runtestsforrecentdb:test:prepare

raketest:uncommitted

#Runtestsforuncommitteddb:test:prepare

raketest:units

#Runtestsforunitsdb:test:prepare

raketmp:cache:clear

#清空tmp/cache目录下的所有文件

raketmp:clear

#清空session,cache,和socket文件从tmp/目录

raketmp:create

#为sessions,cache,andsockets创建tmp/目录

raketmp:sessions:clear

#清空所有在tmp/sessions目录下的文件

raketmp:sockets:clear

# 清空所有在tmp/sessions 目录下的ruby_sess.* 文件
 
rails 2.0新增的Rake Tasks

rakeroutes:打印当前路由列表;

rakedb:drop,rakedb:drop:all,删除当前环境或config/database.yml中的所有数据库;

rakedb:create,rakedb:create:all,创建当前环境数据库或或config/database.yml中的所有数据库;

rakedb:version,显示当前环境数据库的schema版本号;

rake db:reset, 删除并重新创建当前环境的数据库。

1.4Scripts

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.5Generators

rubyscript/generatemodelModelName

rubyscript/generatecontrollerListControllershowedit

rubyscript/generatescaffoldModelNameControllerName

rubyscript/generatemigrationAddNewTable

rubyscript/generatepluginPluginName

rubyscript/generatemailerNotificationlost_passwordsignup

rubyscript/generateweb_serviceServiceNameapi_oneapi_two

rubyscript/generateintegration_testTestName

rubyscript/generatesession_migration

可选项:

-p,--pretendRunbutdonotmakeanychanges.

-f,--forceOverwritefilesthatalreadyexist.

-s,--skipSkipfilesthatalreadyexist.

-q,--quietSuppressnormaloutput.

-t,--backtraceDebugging:showbacktraceonerrors.

-h,--helpShowthishelpmessage.

-c,--svnModifyfileswithsubversion.(Note:svnmustbeinpath)

1.6Plugins

script/plugindiscover

#discoverpluginrepositories

script/pluginlist

#listallavailableplugins

script/plugininstallwhere

#installthea€wherea€?plugin

script/plugininstall-xwhere

#installwherepluginasSVNexternal

script/plugininstallhttp://invisible.ch/projects/plugins/where

script/pluginupdate

#updateinstalledplugins

script/pluginsource

#addasourcerepository

script/pluginunsource

#removesasourcerepository

script/pluginsources

#listssourcerepositories

相关推荐