Singular table names testing

I’ve demoed my rails app and now have to move it to a MSSQL DB. the big
problem I’m running into is the table name conventions I have to use.

I have to use names like tbl_Transfer & tbl_User. In my tests on the
console, I am trying

myvar = tbl_Transfer.find_by_sql(“select top 1 * from tbl_Transfer”)

NameError: undefined local variable or method `tbl_Transfer’ for
#Object:0xb7fec970
from (irb):1

what should go into the myvar= section? the TableName correct?

thanks

-zaq

On Apr 3, 2006, at 21:03, zac elston wrote:

I have to use names like tbl_Transfer & tbl_User. In my tests on the
console, I am trying

myvar = tbl_Transfer.find_by_sql(“select top 1 * from tbl_Transfer”)

NameError: undefined local variable or method `tbl_Transfer’ for
#Object:0xb7fec970
from (irb):1

what should go into the myvar= section? the TableName correct?

In the above case, my guess is you need a model like:

class Transfer < ActiveRecord::Base
set_table_name ‘tbl_Transfer’
end

Then you’d be able to do

all_my_transfers = Transfer.find(:all)

Tablenames are generally abstracted away from your Rails application.
It just happens to be that models are usually named after your
tables. Your variables you can name anything.


Jakob S. - http://mentalized.net