# Legacy database problem

**URL:** <https://www.ruby-forum.com/t/legacy-database-problem/60252>\
**Category:** Rails\
**Created:** [May 11, 2006, 5:08pm UTC](https://www.ruby-forum.com/t/legacy-database-problem/60252 "2006-05-11T17:08:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![victorfan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@victorfan](https://www.ruby-forum.com/u/victorfan)\
**Post date:** [May 11, 2006, 5:08pm UTC](https://www.ruby-forum.com/t/legacy-database-problem/60252/1 "2006-05-11T17:08:12Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![victorfan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@victorfan](https://www.ruby-forum.com/u/victorfan)\
**Post date:** [May 11, 2006, 5:35pm UTC](https://www.ruby-forum.com/t/legacy-database-problem/60252/2 "2006-05-11T17:35:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victorfan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@victorfan](https://www.ruby-forum.com/u/victorfan)\
**Post date:** [May 11, 2006, 5:43pm UTC](https://www.ruby-forum.com/t/legacy-database-problem/60252/3 "2006-05-11T17:43:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![victorfan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@victorfan](https://www.ruby-forum.com/u/victorfan)\
**Post date:** [May 11, 2006, 5:54pm UTC](https://www.ruby-forum.com/t/legacy-database-problem/60252/4 "2006-05-11T17:54:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![victorfan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e8c25b/32.png) [@victorfan](https://www.ruby-forum.com/u/victorfan)\
**Post date:** [May 11, 2006, 5:55pm UTC](https://www.ruby-forum.com/t/legacy-database-problem/60252/5 "2006-05-11T17:55:57Z")

</div>

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
