Legacy database problem


#1

Hi

I am trying to use Ruby on Rails to work with an existing database. The
problem is that, all the table names begin with a captial letter (e.g.
Products). So I did the following changes

in environment.rb, I’ve added under # Include your application
configuration below
ActiveRecord::Base.pluralize_table_names = false

In class Product, I’ve added
set_table_name “Products”

however, if I try to list all the elements in the Products table
(@products = Product.find(:all)) , I have the following error:
RuntimeError: ERROR C42P01 Mrelation “products” does not exist
Fnamespace.c L200 RRangeVarGetRelid: SELECT * FROM Products

but when I create another table with name “products”, it worked fine.
Is there any way to solve this problem?

Thank you very much!


#2

On May 11, 2006, at 8:08 AM, Victor F. wrote:

set_table_name “Products”

however, if I try to list all the elements in the Products table
(@products = Product.find(:all)) , I have the following error:
RuntimeError: ERROR C42P01 Mrelation “products” does not exist
Fnamespace.c L200 RRangeVarGetRelid: SELECT * FROM Products

but when I create another table with name “products”, it worked fine.
Is there any way to solve this problem?

The table name needs quoting. Active Record does not yet quote table
names.

jeremy


#3

Jeremy K. wrote:

On May 11, 2006, at 8:08 AM, Victor F. wrote:

set_table_name “Products”

however, if I try to list all the elements in the Products table
(@products = Product.find(:all)) , I have the following error:
RuntimeError: ERROR C42P01 Mrelation “products” does not exist
Fnamespace.c L200 RRangeVarGetRelid: SELECT * FROM Products

but when I create another table with name “products”, it worked fine.
Is there any way to solve this problem?

The table name needs quoting. Active Record does not yet quote table
names.

jeremy

Thank you Jeremy

Is that mean I have to rename the Products table to products?


#4

On May 11, 2006, at 8:43 AM, Victor F. wrote:

fine.
Is there any way to solve this problem?

The table name needs quoting. Active Record does not yet quote table
names.

jeremy

Thank you Jeremy

Is that mean I have to rename the Products table to products?

Yes. If you can’t rename it, perhaps you have a database that can
provide an alias or synonym (i.e. alias Products to products)

jeremy


#5

I see, thank you so much for your help

Jeremy K. wrote:

On May 11, 2006, at 8:43 AM, Victor F. wrote:

fine.
Is there any way to solve this problem?

The table name needs quoting. Active Record does not yet quote table
names.

jeremy

Thank you Jeremy

Is that mean I have to rename the Products table to products?

Yes. If you can’t rename it, perhaps you have a database that can
provide an alias or synonym (i.e. alias Products to products)

jeremy