From f9bbd3cb94a72ac17bfd12b48381e61420dda9ec Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 10 Jun 2010 00:51:53 -0400 Subject: [PATCH] items can scope by occupying zone --- app/models/item.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/item.rb b/app/models/item.rb index 7f402f50..02c26bf8 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -11,6 +11,12 @@ class Item < ActiveRecord::Base scope :alphabetize, order('name ASC') + scope :occupying_zone, lambda { |zone_id| + joins('INNER JOIN parents_swf_assets psa ON psa.swf_asset_type = "object" AND psa.parent_id = objects.id'). + joins('INNER JOIN swf_assets sa ON sa.id = psa.swf_asset_id'). + where('sa.zone_id = ?', zone_id) + } + # Not defining validations, since this app is currently read-only def species_support_ids