blob: 2b4fc3cf48cb0465e5a4cde638a675335c0326a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
class License < ActiveRecord::Base
belongs_to :company
belongs_to :well_type
has_one :location
belongs_to :applicant, class_name: 'User', foreign_key: 'user_id'
def self.most_recent(page: 1, per_page: 10)
offset = (page - 1) * per_page
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
|