Created
May 24, 2013 13:12
-
-
Save TXDynamics/5643405 to your computer and use it in GitHub Desktop.
Ruby-Model-For-Legacy-DB
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
# == Schema Information | |
# | |
# Table name: sysdba.INF_FUND | |
# | |
# INF_FUNDID :string(12) not null, primary key | |
# CREATEUSER :string(12) | |
# CREATEDATE :datetime | |
# MODIFYUSER :string(12) | |
# MODIFYDATE :datetime | |
# FUND_CODE :string(32) | |
# FUND_FACT_SHEET :text | |
# MARKETING_CODE :string(128) | |
# NAME :string(256) | |
# OFFSHORE :string(1) | |
# OPEN_FUND :string(1) | |
# FUND_TYPE :string(64) | |
# APPROX_MGMT_FEE :float(53) | |
# APPROX_PREF_FEE :float(53) | |
# REDEMPTION_NOTICE :string(64) | |
# STRATEGY :string(255) | |
# YEAR_END :string(32) | |
# NOTES :text | |
# APPROX_PERF_FEE :float(53) | |
# IMPORTID :string(32) | |
# FUND_CLASS :string(128) | |
# FUND_SERIES :string(128) | |
# PARENT_FUND :string(128) | |
# PARENT_FUNDID :string(32) | |
# JPM_IMPORTID :string(64) | |
# | |
class Fund < ActiveRecord::Base | |
# Changing the database to our EDB db | |
establish_connection "SLX_#{Rails.env}" | |
# Manually setting our table | |
set_table_name "sysdba.INF_FUND" # Whatever you require | |
# Manually set our table name | |
set_primary_key :INF_FUNDID | |
# Make our methods compliant | |
alias_attribute(:id, :INF_FUNDID) | |
alias_attribute(:fund_code, :FUND_CODE) | |
alias_attribute(:fund_name, :NAME) | |
# alias_attribute(:marketing_code, :MARKETING_CODE) | |
alias_attribute(:jpm_importid, :JPM_IMPORTID) | |
alias_attribute(:created_at, :CREATEDATE) | |
alias_attribute(:modified_at, :MODIFYDATE) | |
# Define attributes that can be mass updated | |
attr_accessible :fund_code, :fund_name, :MARKETING_CODE | |
# Begin our scope definitions | |
scope :blank_marketing_codes, where("INF_FUND.MARKETING_CODE is null and INF_FUND.JPM_IMPORTID is not null") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment