Signed-off-by: Darryl L. Pierce <mcpierce(a)gmail.com>
---
app/controllers/products_controller.rb | 6 ++----
app/models/sprint.rb | 4 ++++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/app/controllers/products_controller.rb
b/app/controllers/products_controller.rb
index 0eaae5b..57a1e02 100644
--- a/app/controllers/products_controller.rb
+++ b/app/controllers/products_controller.rb
@@ -52,10 +52,8 @@ class ProductsController < ApplicationController
def show
@title = "#{(a)product.name} (Product)"
@project = @product.project
- @sprints = Sprint.paginate(
- :conditions => ['product_id = ?', @product.id],
- :page => params[:sprint_page],
- :per_page => 10)
+ @sprints = Sprint.for_product(@product.id).paginate(:page =>
params[:sprint_page],
+ :per_page => 10)
@user_stories = UserStory.paginate(
:conditions => ['product_id = ?', @product.id],
:order => 'priority ASC',
diff --git a/app/models/sprint.rb b/app/models/sprint.rb
index c8c4285..d33c0c3 100644
--- a/app/models/sprint.rb
+++ b/app/models/sprint.rb
@@ -73,6 +73,10 @@ class Sprint < ActiveRecord::Base
:dependent => :destroy
has_many :user_stories, :through => :backlog_items, :order => :priority
+ named_scope :for_product, lambda { |product_id|
+ { :conditions => ["product_id = ?", product_id]}
+ }
+
STATUS_PLANNED = 0
STATUS_ACTIVE = 1
STATUS_CLOSED = 2
--
1.6.0.6