From 1abfc6dbff46f35e5d35abbeb130ad449273232b Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Fri, 19 Feb 2010 15:38:01 -0500 Subject: [PATCH] story-status-menu ## Story status menu We're going to do this in two stages - first a fixed menu that would require a source-code change if you ever need to alter the available statuses. We'll then remove that restriction by adding a StoryStatus model. We'll also see the migration generator in action again. The fixed menu is brain-dead simple. Track down the declaration of the status field in `story.rb` (it's in the `fields do ... end` block), and change it to read something like: SHOW_PATCH Job done. If you want the gory details, `enum_string` is a *type constructor*. It creates an anonymous class that represents this enumerated type (a subclass of String). You can see this in action by trying this in the console: >> Story.find(:first).status.class {: .ruby} --- app/models/story.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/story.rb b/app/models/story.rb index c0c55d0..f87cf2d 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -5,7 +5,7 @@ class Story < ActiveRecord::Base fields do title :string body :text - status :string + status enum_string(:new, :accepted, :discussion, :implementation) timestamps end