I have a legacy schema where table names and their colums are all in uppercase.
lass SomeModel < ActiveRecord::Base
self.table_name = 'AUTHOR'
self.primary_key = "AUTH_ID"
alias_attribute :id, 'aut_id'
alias_attribute :first_name, 'aut_first_name'
alias_attribute :last_name, 'aut_last_name'
ignore_table_columns 'AUT_LOGIN'
end
Then I checked it:
author = SomeModel.take
puts author.inspect
puts "first Author: id: #{author.id}, #{author.first_name} #{author.last_name}"
Here is the output:
lib ruby db_oracle_connection.rb
Traceback (most recent call last):
2: from db_oracle_connection.rb:37:in `<main>'
1: from db_oracle_connection.rb:45:in `<class:SomeModel>'
/Users/Serguei/.rvm/gems/ruby-2.5.0/gems/activerecord-5.2.0/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `ignore_table_columns' for SomeModel (call 'SomeModel.connection'
First thing I noticed, - that I had to declare original column names in lower case:
alias_attribute :first_name, 'aut_first_name'
instead of
alias_attribute :first_name, 'AUT_FIRST_NAME'
Another point is, no matter what I pass in to
, nothing works. What is the right way to ignore table columns ? Thank you.