Skip to content

Instantly share code, notes, and snippets.

@jnwheeler44
Created November 3, 2012 06:26
Show Gist options
  • Save jnwheeler44/4006275 to your computer and use it in GitHub Desktop.
Save jnwheeler44/4006275 to your computer and use it in GitHub Desktop.
class Chair < ActiveRecord::Base
belongs_to :person
belongs_to :location
has_one :result
has_many :reports, :through=>:result
scope :with_active_viewed_report, joins(:report).where(:reports => {:active => 1, :viewed => 1})
scope :user_allowed, lambda { |user| where(:person_id => user.permission_owner_ids) }
# TODO: Remove location references; they aren't needed
def self.get_home_page_data(location, user)
user_allowed(user).with_active_viewed_report
end
end
class User < ActiveRecord:Base
def permission_owner_ids
chair_permissions.collect(&:owner_id)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment