# Legacy Table works-except edit?

**URL:** <https://www.ruby-forum.com/t/legacy-table-works-except-edit/89431>\
**Category:** Rails\
**Created:** [January 4, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/legacy-table-works-except-edit/89431 "2006-01-04T18:29:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 4, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/legacy-table-works-except-edit/89431/1 "2006-01-04T18:29:53Z")

</div>

Greetings,

I’m trying to put a Rails face on a Legacy Oracle 10 table. I am  
currently setting the table\_name and primary\_key, and I get the list  
and show to work fine.

However, when I hit edit I just get the Editing

, Edit  
button, Show, and Back. None of the fields are rendered.

Why would I be able to show these fields in the show and list, but not  
edit them in the edit? My DB user has the power to edit them via  
TOAD.

Thanks,  
Joe

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 4, 2006, 7:03pm UTC](https://www.ruby-forum.com/t/legacy-table-works-except-edit/89431/2 "2006-01-04T19:03:03Z")

</div>

I failed to mention that the \_form.rthml is  
\<%= error\_messages\_for ‘ref\_specification’ %\>

But why dosen’t it have the setters in it? The editable coulmns are  
all varchar and date.

Thanks,  
Joe

On 1/4/06, Bothari [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> edit them in the edit? My DB user has the power to edit them via  
> TOAD.
> 
> Thanks,  
> Joe

–  
“For a new software system, the requirements will not be completely  
known until after the users have used it.” Humphrey’s Requirements  
Uncertainty Principle.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 4, 2006, 8:21pm UTC](https://www.ruby-forum.com/t/legacy-table-works-except-edit/89431/3 "2006-01-04T20:21:32Z")

</div>

Just to keep things moving I went ahead and filled in all the values I  
wanted to update.

However, now I have a different problem. When I try to create a new  
object it’s looking for a sequence that doesn’t exist. I want to use  
a user-entered sequence. I know this is generally a bad idea.

I’ve seen some reference to before\_validate\_on\_create, but I don’t  
know what to do with it.

Thanks,  
Joe

On 1/4/06, Bothari [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Joe
> 
> > 
> 
> “For a new software system, the requirements will not be completely  
> known until after the users have used it.” Humphrey’s Requirements  
> Uncertainty Principle.

–  
“For a new software system, the requirements will not be completely  
known until after the users have used it.” Humphrey’s Requirements  
Uncertainty Principle.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 5, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/legacy-table-works-except-edit/89431/4 "2006-01-05T19:57:33Z")

</div>

On 1/4/06, Bothari [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks,
> 
> > all varchar and date.
> > 
> > > However, when I hit edit I just get the Editing
> > > 
> > > , Edit  
> > > button, Show, and Back. None of the fields are rendered.
> > > 
> > > Why would I be able to show these fields in the show and list, but not  
> > > edit them in the edit? My DB user has the power to edit them via  
> > > TOAD.
> > > 
> > > Make sure that you’ve either got the physical tables in the user  
> > > schema your Rails app runs as, or else you have synonyms for them.
> > > 
> > > For example, if your userid in database.yml is “rails”, and you’re  
> > > looking for a table called “specifications”… then this has to work:  
> > > (This is the actual query that the OCIAdapter is executing)
> > > 
> > > select column\_name, data\_type, data\_default, nullable,  
> > > decode(data\_type, ‘NUMBER’, data\_precision, ‘VARCHAR2’, data\_length,  
> > > null) as length,  
> > > decode(data\_type, ‘NUMBER’, data\_scale, null) as scale  
> > > from user\_catalog cat, user\_synonyms syn, all\_tab\_columns col  
> > > where cat.table\_name = ‘SPECIFICATIONS’  
> > > and syn.synonym\_name (+)= cat.table\_name  
> > > and col.table\_name = nvl(syn.table\_name, cat.table\_name)  
> > > and col.owner = nvl(syn.table\_owner, user)
> > > 
> > > If you can wade through that mess, you can see that the table name has  
> > > to either appear in USER\_CATALOG, or USER\_SYNONYMS, or both, in order  
> > > for Rails to fetch the proper list of attributes for your model  
> > > objects.
> > > 
> > > If the table is in the “OTHER” schema instead of the “RAILS” schema,  
> > > you’ll need to do:  
> > > CREATE SYNONYM RAILS.SPECIFICATIONS FOR OTHER.SPECIFICATIONS  
> > > Do that for every model table, and you should be good to go.
> > > 
> > > It would be nice if there were a config option for the Oracle adapter  
> > > that let you specify which schema the tables are in. That way you  
> > > could do: ActiveRecord::Base.default\_schema = “OTHER”  
> > > …and ActiveRecord would qualify all its SQL queries with  
> > > OTHER.TABLE\_NAME
> > > 
> > > To override the sequence name, put this in your model:
> > > 
> > > class Specification \< ActiveRecord::Base  
> > > set\_sequence\_name “crazy\_legacyseq”  
> > > end
