class Post < ActiveRecord::Base
STATUS = %w(draft published)
def draft?
status == 'draft'
end
def published?
status == 'published'
end
endchanges to
class Post < ActiveRecord::Base
enum status: %w(draft published)
end# Query method
post.draft?
post.published?
# Action method
post.draft!
post.published!