njazari/sef-founderwall

View on GitHub
app/models/hospital.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'will_paginate' 
class Hospital < ActiveRecord::Base
    has_many :dedications
    has_many :donors, :through => :dedications
    
    def self.options_for_select
        order('name').map { |e| [e.name, e.id] }
    end
    
    after_initialize do 
        if new_record? then if self.status.nil? then self.status = true end end end
            
    def published_dedications_by_tier
        dbt = Hash.new
        Dedication.tiers.each do |tier|
            dbt[tier] = Dedication.where(:hospital => self.id, :tier => tier, :status => true, :published => true)
        end
        dbt
    end
end