Skip to content

Instantly share code, notes, and snippets.

@arwagner
Created September 28, 2011 14:25
Show Gist options
  • Save arwagner/1248072 to your computer and use it in GitHub Desktop.
Save arwagner/1248072 to your computer and use it in GitHub Desktop.
class DepositController < ApplicationController
def index
@deposit = Deposit.search(search_param)
@deposit_presenter = DepositPresenter.new(deposit)
end
end
# this should either be in lib, or in app/presenters or something
class DepositPresenter
def initialize(search)
@search = search
@search.meta_sort ||= 'deposit_date.desc'
end
def current_user_is_admin?
has_role? :admin
end
def deposits
if current_user_is_admin?
@search.all(:limit => 5000).paginate(:page => page_param)
else
@search.all(:limit => 5000, :conditions => ['deposit_date > ?', 2.years.ago]).paginate(:page => page_param)
end
end
def depositsAP
if current_user_is_admin?
@search.ap(:deposit).my_order(:deposit)
else
@search.for_office(:deposit).ap(:deposit).my_order(:deposit)
end
end
# similar definitions for depositsPP and depositsMISC
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment