Mime::Type の register メソッドで定義される定数
Mime::Type.register は、登録された Mime::Type ではなく拡張子の配列を返す、という謎の挙動になっている。
ActiveRecord::Base.with_failsave (2)
実際に ActiveRecord::Base.with_failsave でテストを書いているうちに、いくつか使い勝手の悪い部分が見つかった。というわけで、すこし改良。
ActiveRecord::Base.with_failsave
failmalloc の精神で、必ず失敗する ActiveRecord::Base#save を書いてみた。
Rails の Migration で MySQL の型を指定する
たとえば、こんな感じの Migration を考えてみる。
class CreatePepsi < ActiveRecord::Migration
def self.up
create_table :pepsies do |t|
t.column :coke, :string, :limit => 64
t.column :jolt, :integer
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
end
def self.down
drop_table :addresses
end
end
Rails 2.0 で追加された Migration 関連の Rake タスク
- db:migrate:reset
- DROP DATABASE して db:migrate
- 毎回、VERSION=0 とか指定していたので、こういうのが欲しかった
- 問答無用で DEFAULT CHARACTER SET 'utf8' な気もするが...
- db:migrate:redo [STEP=n]
- STEP で指定した数だけ遡って db:migrate をやりなおす
- STEP のデフォルトは 1