[Rails] Scaffolding an existing Oracle DB

Kevin Williams kevin at bantamtech.com
Tue Mar 1 05:39:46 GMT 2005


I spent a few minutes looking into this a bit deeper.

It appears that the current Oracle adapter cannot handle schema names. 
It also seems the SQL Server adapter can't either, but I haven't tried 
it. The PostgreSQL adapter appears to handle it. The problem is that if 
you assign the table_name to be '<schema>.<table>' the adapter cannot 
query table metadata from the system tables by using the table name 
alone. The PostgreSQL adapter has the 'split_table_schema' method to 
handle when to use the schema and when to use the table name alone.

I'm likely wrong, but after 5 minutes of browsing the code this is how 
it looks to me.

On the suggestion of creating "ActiveRecord-friendly" views, that should 
work but I have no control over the database whatsoever. :(

Kevin



Tim Lucas wrote:
> On 26/02/2005, at 2:31 AM, Kevin Williams wrote:
> 
>> I wonder if anyone else has tackled this problem already. I have an 
>> existing database that I want to Rails-enable. The "five minute magic" 
>> window has come and gone, and I still can't get it to work. All the 
>> scaffolded views don't show any fields at all, just the "Show", 
>> "Edit", and "Destroy" methods.
> 
> 
> Anything in the error logs?
> 
>> :snip
>>
>> I suspect that the naming scheme in the database is not 
>> ActiveRecord-friendly. Does anyone know how I could get the model to 
>> be scaffolded easily?
> 
> 
> Create some views against the current tables that follow the AR 
> conventions.
> 
> See Neville Burnell's post, as hes sucessfully done this using SQL Server:
> http://article.gmane.org/gmane.comp.lang.ruby.rails/3374
> 
>> Does anyone know a better way to handle the schema prefix? I suspect 
>> the answer might be RTFM, but I haven't gotten through much of it yet.
> 
> 
> Not sure if there's a param you can pass to the oracle adaptor in the 
> config file to specify the schema prefix for all tables. You may have to 
> override table_name in each AR class.
> 
> - tim lucas
> 
> http://www.toolmantim.com
> 
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails

----------
Scanned for viruses by ClamAV


More information about the Rails mailing list