rakeのタスク一覧

rake db
rake doc
rake gems
rake log
rake middleware
rake notes
rake rails
rake routes
rake secret
rake stats
rake test
rake time
rake tmp

[参考記事] rake --helpとrake -Tの実行結果

rake -T

rakeタスクの一覧を表示する。

rake db:abort_if_pending_migrations

Raises an error if there are pending migrations

実行されてないmigrationを表示する。

rake db:charset

Retrieves the charset for the current environment's database

データベースの文字コードを表示する。
mysql以外は下記のエラーが出ます。
sorry, your database adapter is not supported yet, feel free to submit a patch

rake db:collation

Retrieves the collation for the current environment's database

データベースの照合順序を表示する。
mysql以外は下記のエラーが出ます。
sorry, your database adapter is not supported yet, feel free to submit a patch

rake db:create

Create the database defined in config/database.yml for the current RAILS_ENV

database.ymlの設定内容でデータベースを作る。

RAILS_ENVオプション

標準ではdevelopment環境の設定からデータベースの作成を行います。
testやproduction環境の設定を使用する場合はRAILS_ENVオプションを指定します。

rake db:create RAILS_ENV=production

rake db:create:all

Create all the local databases defined in config/database.yml

database.ymlに定義してあるデータベースを全て作る。

rake db:drop

Drops the database for the current RAILS_ENV

database.ymlの設定内容でデータベースを削除する。

RAILS_ENVオプション

標準ではdevelopment環境の設定からデータベースの削除を行います。
testやproduction環境の設定を使用する場合はRAILS_ENVオプションを指定します。

rake db:drop RAILS_ENV=production

rake db:drop:all

Drops all the local databases defined in config/database.yml

database.ymlに定義してあるデータベースを全て削除する。

rake db:fixtures:identify

Search for a fixture given a LABEL or ID. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures.

fixtureファイルのLABELやIDからデータを探してくれる。

rake db:fixtures:identify LABEL=one

rake db:fixtures:load

Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y. Load from subdirectory in test/fixtures using FIXTURES_DIR=z. Specify an alternative path (eg. spec/fixtures) using FIXTURES_PATH=spec/fixtures.
test/fixtures 以下に置いた、【テーブル名】.yml というYAMLファイルをDBに登録する。

FIXTURESの後にテーブル名カンマで続けて複数も可能です。

rake db:fixtures:load FIXTURES=users,items

rake db:migrate

Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false.
db/migrate内のスクリプトファイルからdatabaseにテーブル作成する。

rake db:migrate:down

Runs the "down" for a given migration VERSION.

指定したmigrationファイルのself.downメソッドを実行する。

rake db:migrate:down VERSION=200912030132

rake db:migrate:redo

Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x. Target specific version with VERSION=x.

migrationを指定したSTEP数だけ切り戻して再度実行する。
例えば現在のmigrationのバージョンが100で、STEPが1だったら、一旦99に戻してから100を実行してくれる。

STEPの指定はSTEP=nで。デフォルトは1

rake db:migrate:redo STEP=5

rake db:migrate:reset

Resets your database using your migrations for the current environment

drop、create、migrate全てやる。
databaseを一度削除してもう一度作成し、db:migrate実行する。

rake db:migrate:up

Runs the "up" for a given migration VERSION.

指定したmigrationファイルのself.upメソッドを実行する。

rake db:reset

Drops and recreates the database from db/schema.rb for the current environment and loads the seeds.

drop、createし、schema.rbから復帰させる。

db:migrate:resetと違い、migration実行するのではなく、schema.rbから復帰させる。

rake db:rollback

Rolls the schema back to the previous version. Specify the number of steps with STEP=n

migrationのバージョンを指定したSTEP数だけ切り戻す。

STEPの指定はSTEP=nで。デフォルトは1

rake db:schema:dump

Create a db/schema.rb file that can be portably used against any DB supported by AR

ARに読み込める形のschemaファイルをdb/schema.rbを作成する。

rake db:schema:load

Load a schema.rb file into the database

db/schema.rbの内容をデータベースに読み込む。

rake db:seed

Load the seed data from db/seeds.rb

db/seeds.rbをデータベースに読み込む。

[参考記事] db/seed.rbで初期データ投入

rake db:sessions:clear

Clear the sessions table

sessionテーブルの中身を削除する。

rake db:sessions:create

Creates a sessions migration for use with ActiveRecord::SessionStore

sessionテーブルを作成する。

rake db:setup

Create the database, load the schema, and initialize with the seed data

データベース、テーブルを作成し、初期データを投入する。

rake db:structure:dump

Dump the database structure to a SQL file

DB構成をSQLファイルにして出力する。
出力先はdb以下に。データは入れない。

rake db:test:clone

Recreate the test database from the current environment's database schema

現在の利用しているdatabase環境をtest環境に作成する。

rake db:test:clone_structure

Recreate the test databases from the development structure

開発環境の構成とtest環境用のDBと同期をとることを可能にする。

rake db:test:load

Recreate the test database from the current schema.rb

指定したschema.rbからtest環境databaseを作成する。

rake db:test:prepare

Check for pending migrations and load the test schema

テスト用schemaを読み込んでmigrationにpendingがないかチェックする。

rake db:test:purge

Empty the test database

テスト環境DBを空にする。

rake db:version

Retrieves the current schema version number

現在のマイグレーションのバージョンを表示する。


rake doc:app

Build the RDOC HTML Files

現在のアプリのドキュメントファイルを作成する。

rake doc:clobber_app

Remove rdoc products

アプリのドキュメントファイルを削除する。

rake doc:clobber_plugins

Remove plugin documentation

プラグインドキュメントを削除する。

rake doc:clobber_rails

Remove rdoc products

railsドキュメントを削除する。

rake doc:guides

Generate Rails guides

rake doc:plugins

Generate documentation for all installed plugins

プラグインに関するドキュメントを作成する。

rake doc:rails

Build the RDOC HTML Files

railsに関するドキュメントを作成する。

rake doc:reapp

Force a rebuild of the RDOC files

現在あるドキュメントを強制的に上書きする。

rake doc:rerails

Force a rebuild of the RDOC files

現在あるドキュメントを強制的に上書きする。


rake gems

List the gems that this rails application depends on

railsアプリに必要なライブラリをlistとして表示する。

rake gems:build

Build any native extensions for unpacked gems

vendor/plugins以下のgemをnative extensionとしてbuildする。

rake gems:build:force

Force the build of all gems

rake gems:install

Installs all required gems.

アプリに必要なgemをインストールする。

rake gems:refresh_specs

Regenerate gem specifications in correct format.

rake gems:unpack

Unpacks all required gems into vendor/gems.

プロジェクトに必要なgemをvendor/plugins以下にコピーする。

rake gems:unpack:dependencies

Unpacks all required gems and their dependencies into vendor/gems.

gem:unpackに依存しているgemをコピーする。


rake log:clear

Truncates all *.log files in log/ to zero bytes

log/*.logファイルを0byteにする。


rake middleware

Prints out your Rack middleware stack


rake notes

Enumerate all annotations

FIXME,OPTIMIZE,TODOが入力されている行を出力する。

rake notes:custom

Enumerate a custom annotation, specify with ANNOTATION=WTFHAX

rake notes:fixme

Enumerate all FIXME annotations

FIXMEが入力されている行を出力する。

rake notes:optimize

Enumerate all OPTIMIZE annotations

OPTIMIXEが入力されている行を出力する。

rake notes:todo

Enumerate all TODO annotations

TODOが入力されている行を出力する。


rake rails:freeze:edge

Lock to latest Edge Rails, for a specific release use RELEASE=1.2.0

最新バージョンのrailsに固定する。
RELEASEでバージョンが指定できる。

rake rails:freeze:gems

Lock this application to the current gems (by unpacking them into vendor/rails)

gemをvendor/rails以下におくことでバージョン固定する。

rake rails:template

Applies the template supplied by LOCATION=/path/to/template

rake rails:unfreeze

Unlock this application from freeze of gems or edge and return to a fluid use of system gems

gemの固定を解除する。

rake rails:update

Update both configs, scripts and public/javascripts from Rails

script,config,public/javascripts内を更新する。

rake rails:update:application_controller

Rename application.rb to application_controller.rb

rake rails:update:configs

Update config/boot.rb from your current rails install

config/boot.rbを更新する。

rake rails:update:generate_dispatchers

Generate dispatcher files in RAILS_ROOT/public

rake rails:update:javascripts

Update your javascripts from your current rails install

public/javascripts内を更新する。

rake rails:update:scripts

Add new scripts to the application script/ directory

script内を更新する。


rake routes

Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.

ルーティングをすべて表示する。


rake secret

Generate a crytographically secure secret key.

ランダムな英数字を返する。


rake stats

Report code statistics (KLOCs, etc) from the application

アプリ内のコーディング数を表示する。


rake test

Run all unit, functional and integration tests

全てのunitテストとfunctionalテストとintegrateテストを実行する。

rake test:benchmark

Run tests for benchmarkdb:test:prepare / Benchmark the performance tests

rake test:functionals

Run tests for functionalsdb:test:prepare / Run the functional tests in test/functional

test/functional以下のテストを実行する。

rake test:integration

Run tests for integrationdb:test:prepare / Run the integration tests in test/integration

test/integration以下のテストを実行する。

rake test:plugins

Run tests for pluginsenvironment / Run the plugin tests in vendor/plugins/*/**/test (or specify with PLUGIN=name)

plugins以下にあるtestを実行する。プラグインの名前も指定可能。

rake test:profile

Run tests for profiledb:test:prepare / Profile the performance tests

rake test:recent

Run tests for recentdb:test:prepare / Test recent changes

最近変更があった箇所のテストを実行する。

rake test:uncommitted

Run tests for uncommitteddb:test:prepare / Test changes since last checkin (only Subversion and Git)

Subversionの最後のチェックインからテストを実行する。

rake test:units

Run tests for unitsdb:test:prepare / Run the unit tests in test/unit

test/unit内のテストを実行する。


rake time:zones:all

Displays names of all time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6

railsが理解できるタイムゾーンクラスを表示する。

rake time:zones:local

Displays names of time zones recognized by the Rails TimeZone class with the same offset as the system local time

システムのlocaltimeと同じオフセットのタイムゾーンクラスの名前を表示します。

rake time:zones:us

Displays names of US time zones recognized by the Rails TimeZone class, grouped by offset. Results can be filtered with optional OFFSET parameter, e.g., OFFSET=-6

USのタイムゾーンを表示する。


rake tmp:cache:clear

Clears all files and directories in tmp/cache

tmp/cache内のファイルを削除する。

rake tmp:clear

Clear session, cache, and socket files from tmp/

tmp内のcache,session,pidsファイルなどをクリアする。

rake tmp:create

Creates tmp directories for sessions, cache, sockets, and pids

railsプロジェクト内のtmp/にsession,cache,pidsディレクトリを作成する。

rake tmp:pids:clear

Clears all files in tmp/pids

pidsディレクトリ内をクリアする。

rake tmp:sessions:clear

Clears all files in tmp/sessions

sessionsディレクトリ内をクリアする。

rake tmp:sockets:clear

Clears all files in tmp/sockets

socketsディレクトリ内をクリアする。

関連記事

スポンサーリンク

Windows11でオフラインアカウントを作成する方法(Microsoftアカウントを使わない)

ホームページ製作・web系アプリ系の製作案件募集中です。

上に戻る