From d0aaa1ee5724c4981aba10efeb7e9abde27da13d Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 21 Feb 2014 23:29:26 -0700 Subject: add integration test and add township query method. --- app/models/company.rb | 2 +- app/models/license.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/company.rb b/app/models/company.rb index 4b6e798..7691bf5 100644 --- a/app/models/company.rb +++ b/app/models/company.rb @@ -2,6 +2,6 @@ class Company < ActiveRecord::Base has_many :licenses def status(status) - status.filter(licenses) + licenses.status(status) end end diff --git a/app/models/license.rb b/app/models/license.rb index 6170683..77aad5f 100644 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -9,4 +9,12 @@ class License < ActiveRecord::Base offset = offset >= 0 ? offset : 0 License.order(created_at: :desc).offset(offset).limit(per_page) end + + def self.township(township) + joins(:location).where('locations.township = ?', township) + end + + def self.status(status) + status.filter(self) + end end -- cgit v1.2.3