Tutorial for mapping differently-named tables?

I am interested in testing Rails with a database whose tables are not
named according to Ruby standards.The tables do do not use PLURAL
names, and they use underscores.

For example, I have a table called bbc_customer that I would like to
use.

Any good sites which discuss how to customize in this way? thanks!

There’s always the ActiveRecord documentation at api.rubyonrails.com.

There is a meta-function in ActiveRecord::Base named ‘set_table_name’ that allows you to override the default table name. So in your case:

class Customer < AR::Base
set_table_name ‘bbc_customer’
end

However, if all of your tables start with bbc_, then you can add a line to your config.rb:

ActiveRecord::Base.table_name_prefix = ‘bbc_’

ActiveRecord::Base.pluralize_tables = false # May have to look this one up, I can’t remember

As for a webpage that describes all of the AR config settings, I’m not able to find one. Your best bet is to just look into the active_record source, starting with active_record/base.rb.

Jason

Ah, it’s:

ActiveRecord::Base.pluralize_table_names = false

It is all in base.rb, all the class-level variables.

Jason

That was just what I needed. Thanks for your help.