mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-07 21:38:14 -08:00
dirty commit: can't get references to work correctly between any tables
This commit is contained in:
parent
e1f0b78236
commit
a4fddbeced
183 changed files with 5461 additions and 5 deletions
31
app/models/dashboard/income.rb
Normal file
31
app/models/dashboard/income.rb
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
module Dashboard
|
||||
class Income < ApplicationRecord
|
||||
scope :by_designation, -> { all.map { |income| [income.designation, income] }.to_h }
|
||||
scope :by_slug, -> { all.map { |income| [income.slug, income] }.to_h }
|
||||
|
||||
include FriendlyId
|
||||
|
||||
friendly_id :designation, use: [:slugged]
|
||||
|
||||
def self.to_designation(income)
|
||||
case income
|
||||
in /Free\s*Lunch|Reduced\s*Lunch|Low\s*Income|Reduced\s*price\s*lunch/i
|
||||
"Economically Disadvantaged - Y"
|
||||
in /Not\s*Eligible/i
|
||||
"Economically Disadvantaged - N"
|
||||
else
|
||||
"Unknown"
|
||||
end
|
||||
end
|
||||
|
||||
LABELS = {
|
||||
"Economically Disadvantaged - Y" => "Economically Disadvantaged",
|
||||
"Economically Disadvantaged - N" => "Not Economically Disadvantaged",
|
||||
"Unknown" => "Unknown"
|
||||
}
|
||||
|
||||
def label
|
||||
LABELS[designation]
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue