- 複数列の組み合わせで unique 制約を設定するには,
add_index :table, [:column1, :column2], :unique => true
のように書く (how to validate uniqueness across multiple columns in ActiveRecord? - Ruby Forum) - データベースのオブジェクトを drop するには,
rake db:migrate VERSION=0
とする.--trace
オプションで詳細な実行結果が出力される.--dry-run
オプションで dry run ができる (how to drop table and recreate the table using migrate - Ruby Forum) -
テストのためのデータベースを作成するには,
rake db:test:prepare
とする (「つぶやき」アプリを改修してみよう(前編) − @IT).rake db:test:load
はRecreate the test database from the current
.db/schema.rb
rake db:test:purge
によってEmpty the test database
(Ruby on Rails Guides: A Guide to Testing Rails Applications).--trace
オプションで詳細な実行結果が出力される - rails.el まとめ - ひげぽん OSとか作っちゃうかMona-
- Plugin foreigner:外部キー制約
- Ruby on Rails ActiveRecord Validation - Stack Overflow,ActiveRecordのvalidate - Never forget your first resolution.:独自の validation.API Docs:ActiveRecord::Validations::ClassMethods,ActiveRecord::Validations::ClassMethods
- ActiveRecord::Callbacks:API Doc
rails plugin --verbose install a_plugin
のようにして plugin をインストールする.しかし,
のように失敗したとき,Plugins will be installed using http fetching from 'a_plugin' Plugin not found: ["a_plugin"] #<Errno::ENOENT: No such file or directory - a_plugin>
vendor/plugins/a_plugin/
ディレクトリが残ってしまう.そうすると,再度インストールしようとしてもalready installed
とのメッセージが出てインストールされない.rails plugin --verbose remove a_plugin
によってこの空ディレクトリを削除できる- Rails での拡張:Railsアプリ内でRailsプラグインやGem、Rubyライブラリを拡張する方法 - RAILS PRESS,Extending a rails plugin - Stack Overflow,Strictly Untyped: Rails: Where to put the 'other' files,moco β版 更新ログ: [Rails][プラグイン]acts_asプラグインの作りかた - 超入門 -
参考とすべき文献
- try ruby! (in your browser):
try ruby! (in your browser)
- Rails for Zombies:
You'll watch five videos, each followed by exercises where you'll be programming Rails in your browser
.Ruby on Rails よりリンクされていた - Ruby on Rails Guides: Getting Started with Rails:チュートリアル.Ruby on Rails チュートリアル集 | Diaspar Journal にリストされていた
- Rubyリファレンスマニュアル - Rubyリファレンスマニュアル
- Ruby on Rails:API Doc
- Rubyist Magazine - Search Results (連載「RubyOnRails を使ってみる」を検索)