ruby - ActiveRecord ignores table_name_prefix -


i've got situation need define table_name , table_name_prefix within model , reason table_name overrides table_name_prefix.

class scheduleitem < activerecord::base   self.table_name = "schedule_item"   self.table_name_prefix = 'acq_ibm_t.' end 

the prefix ignored in queries. but, when comment out table_name part prefix added. has seen strange behavior before?

in activerecord::modelschema::classmethods, table_name setter puts value in @table_name:

def table_name=(value)   ...   @table_name        = value 

and table_name getter uses @table_name value if defined:

def table_name   reset_table_name unless defined?(@table_name)   @table_name end 

the table_name_prefix used rails when trying guess table name based on class name (in reset_table_name).

if have table name rails can't guess, can this:

class scheduleitem < activerecord::base   self.table_name = "acq_ibm_t.schedule_item" 

or if need use prefix somewhere else, can this:

class scheduleitem < activerecord::base   self.table_name_prefix = 'acq_ibm_t.'   self.table_name = "#{table_name_prefix}schedule_item" 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -