I'm probably out of my depth here, but since you're not doing any writing, I 
wonder if you could get a view together on the oracle side that UNIONS the data 
from your various ClaimExtra tables, and then point rails at that as the source 
'table' for ClaimExtra?

You could maybe even get fancy and pretend to be doing Single Table Inheritance 
on that view, if you wanted to e.g., have distinct DeniedTypeAClaim and 
SuspendedTypeBClaim classes...

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of 
Reacher
Sent: Wednesday, September 10, 2008 12:49 PM
To: Ruby on Rails: Talk
Subject: [Rails] legacy database and set_table_name


I'm trying like crazy to wrap a rails app around a legacy oracle database.  
This app will not be mutating any data in the database, only viewing it.  
Here's a 30 second description of the "schema".

There is a master table for a health care claim (I will call it claim_master), 
and this table has a unique id for the claim, as well as a type and a status.  
Type can be 1 of about a dozen possible values.  Status is either paid, 
suspended or denied.  Then we have several other tables, split up by claim type 
and status, that hold extra claims data.  So claims of type A with a paid 
status would be in, say, claims_a_paid and a claim with type B  with a deny 
status would be in claim_b_deny.

I want to set up my models with associations, but the association must depend 
on values in the database.  Take this:

class Claim < ActiveRecord::Base
  has_one :extra
  set_table_name "claim_master"
end

class ClaimExtra < ActiveRecord::Base
  belongs_to :claim
  set_table_name "???"
end

The table name that belongs where the ??? is depends on data in the claim.  Is 
there any rails magic I can use that can let this table name be dynamically 
constructed out of the results from the belongs_to directive being executed?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to