度々忘れるのでメモしておきます。

   1  Merb::ControllerExceptions.constants.sort #=> ["Accepted", "ActionNotFound", "BadGateway", "BadRequest", "Base", "ClientError", "Conflict", "Continue", "Created", "ExpectationFailed", "Forbidden", "GatewayTimeout", "Gone", "HTTPVersionNotSupported", "Informational", "InternalServerError", "LayoutNotFound", "LengthRequired", "MethodNotAllowed", "MovedPermanently", "MovedTemporarily", "MultiPartParseError", "MultipleChoices", "NoContent", "NonAuthoritativeInformation", "NotAcceptable", "NotFound", "NotImplemented", "NotModified", "OK", "PartialContent", "PaymentRequired", "PreconditionFailed", "ProxyAuthenticationRequired", "Redirection", "RequestEntityTooLarge", "RequestRangeNotSatisfiable", "RequestTimeout", "RequestURITooLarge", "ResetContent", "STATUS_CODES", "SeeOther", "ServerError", "ServiceUnavailable", "Successful", "SwitchingProtocols", "TemplateNotFound", "TemporaryRedirect", "Unauthorized", "UnsupportedMediaType", "UseProxy"]

posted by Png genki on Sat 4 Apr 2009 at 22:58

Merb/DataMapper/CouchDBの環境で rspec を使う場合には、 spec_helper.rb で以下のように設定すると良いようです。

   1    config.before(:all) do
   2      DataMapper::AutoMigrator.auto_migrate(nil,
   3        *(DataMapper::Resource.descendants - [Merb::DataMapperSessionStore]))
   4    end

セッションストアを使っている場合は、 Merb::DataMapperSessionStore用のrepositoryを 別途指定すると良いと思います。

posted by Png genki on Sat 4 Apr 2009 at 22:11

DataMapper#auto_migrate!を実行すると、以下のようなコードが実行される。

   1  self.auto_migrate!(repository_name = nil)
   2    AutoMigrator.auto_migrate(repository_name)
   3  end

AutoMigrator#auto_migrateは以下のようになっている。

   1  def self.auto_migrate(repository_name = nil, *descendants)
   2    auto_migrate_down(repository_name, *descendants)
   3    auto_migrate_up(repository_name, *descendants)
   4  end

第二引数以降でDMのクラスリストを指定できる。 省略すると、DataMapper::Resource.decendantsが指定されたものとして動作する。 特定のリソースだけまとめてauto_migrateするには便利そうだ。

posted by Png genki on Sat 4 Apr 2009 at 21:58
Contents
Merb::Controllerであらかじめ定義されている例外クラス
Merb/DM/CouchDBでrspecを使う場合の設定メモ
DM#auto_migrate!に関するメモ
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
瀧内元気: おお、チェックしてみます。thx! '11-12
overisland: Reeder for iPhone もこの UI を実装していますね。 '11-12
瀧内元気: その情報は見たのですが、以下のサイトによると、現在はまた必要になってるっぽいんですよね。 ... '11-12
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ