#4 scaffoldでRailsアプリケーションを作成
Railsを覚えようと思った理由の1つがscaffoldが使ってみたかったためです。アプリケーションに必要なスケルトンをコマンド1つで作成できるという優れものです。とりあえず本の通りにやってみました。
とりあえず、helpでコマンドを確認する
$ ruby script/generate scaffold --help
Usage: script/generate scaffold ModelName [ControllerName] [action, ...]
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
General Options:
-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.
-c, --svn Modify files with subversion. (Note: svn must be in path)
・・・省略
とりあえず、以下のコマンドで生成されるようです。
ruby script/generate scaffold [model_name] [controller_name]
それでは、実行してみます。
$ ruby script/generate scaffold project mytask
exists app/controllers/
exists app/helpers/
exists app/views/mytask
exists app/views/layouts/
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
・・・省略
これでスケルトンが生成されました。本当に簡単ですね。
トラックバック(0)
このブログ記事に対するトラックバックURL(トラックバックは承認後に公開されます)


コメントする