forked from bryanlarsen/agility-gitorial-patches
-
Notifications
You must be signed in to change notification settings - Fork 1
/
30-story-status-belongs-to-story.patch
44 lines (35 loc) · 1.37 KB
/
30-story-status-belongs-to-story.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
story-status-belongs-to-story
From: Bryan Larsen <[email protected]>
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?