table_name_suffix
This attribute is also set directly on the ActiveRecord::Base class; it allows you to define the
suffix to be used with all tables throughout your Active Record instances. When you do not set
this attribute, the default suffix used is an empty string (which equates to no suffix being used).
The following example states that all of our tables should have the string "draftwizard_"
attached as a suffix:
# Setting the table_name_suffix
ActiveRecord::Base.table_name_suffix = "_draftwizard"
class Account < ActiveRecord::Base
end
a = Account.find(1)
#=> executes SQL equal to "Select * from accounts_draftwizard where id = 1"
Much like the table_name_prefix attribute, this attribute is very handy when you are
working within a shared database that has tables for a number of virtual schema. By adding
the project name as a suffix to all your tables, they can be more easily managed within your
DBMS, and by using this attribute, you can also quickly and easily utilize the Active Record
library with your schema.
Pages:
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379