Legacy Table works-except edit?

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

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 [email protected] 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.

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 [email protected] 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.

On 1/4/06, Bothari [email protected] 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