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. I have an existing table in Oracle like this: CREATE TABLE SEARCH_USER_PREFERENCE ( SEARCH_USER_PREFERENCE_ID NUMBER, USER_ID VARCHAR2(50 BYTE), SEARCH_USER_PREFERENCE_NAME VARCHAR2(200 BYTE), SEARCH_TYPE_ID NUMBER, PAGE_SIZE NUMBER, SAVED_SEARCH_YN VARCHAR2(2 BYTE), SELECTED_YN VARCHAR2(2 BYTE) ) The SEARCH_USER_PREFERENCE_ID column is the primary key. I created the controller with scaffolding: class SearchUserPreferencesController < ApplicationController scaffold :search_user_preference end and the model with defined table name and primary key: class SearchUserPreference < ActiveRecord::Base def self.table_name() "schema_owner.search_user_preference" end def self.primary_key() "search_user_preference_id" end end 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? 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. Thanks! Kevin ---------- Scanned for viruses by ClamAV
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
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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails---------- Scanned for viruses by ClamAV
And you don''t want to create synonyms in the schema you want to use for objects you want to use in other schemas? Don''t blame you... -Corey Lawson On Mon, 28 Feb 2005 22:39:46 -0700, Kevin Williams <kevin-P4szbAuRZ8UqDJ6do+/SaQ@public.gmane.org> wrote:> 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-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > ---------- > Scanned for viruses by ClamAV > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >