From 28eb34fe708aff8f05985fb30fe103a1321f7795 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Mon, 3 Jun 2013 16:38:24 +0200 Subject: [PATCH] story-status-belongs-to-story Next, remove the 'status' field from the `fields do ... end` block in the Story model. Then add an association with the StoryStatus model: SHOW_PATCH --- app/models/story.rb | 2 +- app/models/story_status.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/story.rb b/app/models/story.rb index 1722f1f..e2d0489 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -5,13 +5,13 @@ class Story < ActiveRecord::Base fields do title :string body :text - status enum_string(:new, :accepted, :discussion, :implementation) tasks_count :integer, :default => 0, :null => false timestamps end attr_accessible :title, :body, :status, :status_id, :project, :project_id, :tasks belongs_to :project, :inverse_of => :stories, :counter_cache => true + belongs_to :status, :class_name => "StoryStatus", :inverse_of => :stories has_many :tasks, :dependent => :destroy, :inverse_of => :story diff --git a/app/models/story_status.rb b/app/models/story_status.rb index 83ba26b..1c3bcf9 100644 --- a/app/models/story_status.rb +++ b/app/models/story_status.rb @@ -8,6 +8,8 @@ class StoryStatus < ActiveRecord::Base end attr_accessible :name + has_many :stories, :inverse_of => :status + # --- Permissions --- # def create_permitted?