Datamapper更新枚举

时间:2010-11-29 02:24:35

标签: ruby enums datamapper

我的模型看起来像这样:

class Project
    include DataMapper::Resource
    property    :id, Serial
    property    :title, String
    property    :slug,  String
    property    :status, Enum[:open, :closed ], :default => :open
    has n, :issues
end

如何使用Project.update()将枚举的状态更改为关闭?

1 个答案:

答案 0 :(得分:2)

就像那样:

Project.update(:status => :closed)