Created
April 18, 2012 15:04
-
-
Save jeremyevans/2414174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
one: {:name=>"Acme Enterprises, Inc.", :commplanname=>"All Transactions", :policynum=>"21IL909GL341234", :class=>"WORK", :billingtype=>"D", :term=>"A", :territory=>nil, :location=>1, :effective=>2008-10-05 00:00:00 -0500, :expires=>2009-10-04 00:00:00 -0500, :cancelled=>false, :decverified=>nil, :totprem=>#<BigDecimal:1d2da07,'0.1492E4',4(12)>, :policyfee=>#<BigDecimal:1e80cc2,'0.0',1(4)>, :adminfee=>#<BigDecimal:19db869,'0.0',1(4)>, :tax=>#<BigDecimal:1b5f860,'0.0',1(4)>, :otherfee=>#<BigDecimal:1c5822c,'0.0',1(4)>} | |
two: Acme Enterprises, Inc. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'sinatra/reloader' | |
require 'sequel' | |
url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};" + | |
"DBQ=C:\\Users\\denton\\code\\portal\\aademo.mdb;Pwd=;" | |
DB = Sequel.connect(url) | |
Sequel.require('adapters/shared/access') | |
DB.extend Sequel::Access::DatabaseMethods | |
DB.extend_datasets Sequel::Access::DatasetMethods | |
class Policy < Sequel::Model(:Policys) | |
set_primary_key :Recnum | |
def self.find_customer(recnum) | |
with_sql("SELECT name, commplanname, policynum, class, billingtype, term, | |
territory, policys.location, effective, expires, cancelled, decverified, totprem, | |
policyfee, adminfee, tax, otherfee | |
FROM policys | |
LEFT JOIN customers ON policys.custid=customers.custid | |
WHERE policys.recnum=?", recnum).first | |
end | |
end | |
get '/policy/:id' do |id| | |
i = Policy.find_customer(id.to_i) | |
erb "one: <%= one %><p>two: <%= two %>", locals: { | |
one: i[:name], | |
two: i[:name][:name] | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment