Permalink
Browse files

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
  • Loading branch information...
bryanlarsen authored and iox committed Jun 3, 2013
1 parent 2661a8b commit 28eb34fe708aff8f05985fb30fe103a1321f7795
Showing with 3 additions and 1 deletion.
  1. +1 −1 app/models/story.rb
  2. +2 −0 app/models/story_status.rb
View
@@ -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
@@ -8,6 +8,8 @@ class StoryStatus < ActiveRecord::Base
end
attr_accessible :name
has_many :stories, :inverse_of => :status
# --- Permissions --- #
def create_permitted?

0 comments on commit 28eb34f

Please sign in to comment.