On Tuesday 12 April 2005 12:19 pm, Kevin Davis wrote:> In my model I specify: > > class Port < ActiveRecord::Base > def self.table_name() > "port_status" > endChange it to def table_name "port_status" end or even: set_table_name "port_status"
In my model I specify: class Port < ActiveRecord::Base def self.table_name() "port_status" end end .. but when I run rake it fails, telling me: ERROR: relation "ports" does not exist Any ideas? Thanks! Kevin _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks! I got how to do that here: http://wiki.rubyonrails.com/rails/show/HowToUseLegacySchemas.. it should probably be updated (I''d be extremely hesitant to update any docs being brand new to rails) After I changed it, I needed to: 1) create a port_status fixture 2) switch the unit test to use the new fixture That fixed the first of my problems.. now its barfing on ''not null'' constraints in my table, but that should be easy enough to fix, but adding appropriate data to the fixtures should fix that. Kevin http://kevin.is-a-geek.net _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Kevin, Kevin Davis wrote:> I got how to do that here: > http://wiki.rubyonrails.com/rails/show/HowToUseLegacySchemas.. it should > probably be updated (I''d be extremely hesitant to update any docs being > brand new to rails)1) Don''t worry about being new to rails. Considering it''s young age and the high rate of its development, it''s easy for anyone to feel a little ''out of it''. 2) The method you previously cited should work just fine(for what it does).> After I changed it, I needed to: > 1) create a port_status fixture > 2) switch the unit test to use the new fixtureExactly. Since fixtures are purely a mechanism for loading data into tables, their name doesn''t actually reflect the model, but the table instead. This also allow for fixture for join tables(which don''t have any model of their own). -- Lee
Caleb Tennis wrote:>On Tuesday 12 April 2005 12:19 pm, Kevin Davis wrote: > > >>class Port < ActiveRecord::Base >> def self.table_name() >> "port_status" >> end >> >> > >or even: > >set_table_name "port_status" > >Or, self.table_name = ''port_status'' Currently the rails'' Inflector will still not use this to map this table to the model, or the model to the table. You can enable that if you apply patch #950. I know that Inflector is only used to guess table<->class relationships, but I think it should "learn" the relationships if they are specified. No need to limit it to English/one schema only. - Adam