dm-is-remixable
は、Commentなどの複数のリソースにまたがって共用されるがちなリソースをDRYにするためのDataMapperプラグインです。
しかし、Validationのためのコードを記述しても、正常に動作しないという問題がありました。これは、以下のようにすれば解決できます。
ruby>>
module Commentable
include DataMapper::Resource
is :remixable, :suffix => "comment"
(..snip..)
def self.included(base)
base.class_eval do
validates_present :message
end
end
end
<<--
See Also
posted by
genki on Tue 5 May 2009 at 01:54 with 0 comments