Skip to content

Instantly share code, notes, and snippets.

@dbrady
Created May 18, 2011 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrady/977972 to your computer and use it in GitHub Desktop.
Save dbrady/977972 to your computer and use it in GitHub Desktop.
ReportsController - Rails 1.2, circa 2008
class ReportsController < ApplicationController
layout 'home'
def last_login
if current_user.can_view_login_report?
@execs = Acl.find(:all, :include => :user, :conditions => ["access_type='Airport' AND access_id=#{current_airport_id}"]).map { |a| a.user }
operators = Operator.find_all_by_airport_id(current_airport[:id])
@opers = Acl.find(:all, :include => :user, :conditions => ["access_type='Operator' AND access_id IN (?)", operators]).map { |a| a.user }
stores = Store.find_all_by_airport_id(current_airport[:id])
@vendors = Acl.find(:all, :include => :user, :conditions => ["access_type='Store' AND access_id IN (?)", stores]).map { |a| a.user }
@users = @execs + @opers + @vendors
@users = @users.uniq.sort_by {|u| "%-40s%-40s" % [u.last_name, u.first_name]}
else
redirect_to "/"
true
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment