I need to change the name of the table a model is connected to... like the example in the API... the table is called mice and I want a class called Mouse. class Mouse < ActiveRecord::Base table_name "mice" end I''m doing this cause I want tables in my language (italian) and avoid the nameS thing. just adding it in that way doesn''t work ArgumentError in Tipo_trasporti#index wrong number of arguments (1 for 0) /app/models/tipo_trasporti.rb:2:in `table_name'' /app/models/tipo_trasporti.rb:2 script/server:51 someone has suggested to use def: class TipoTrasporti < ActiveRecord::Base def table_name "tipo_trasporto" end end in the controller I''ve got this: class TipoTrasportiController < ApplicationController model :tipo_trasporti def index myvar = TipoTrasporti.find_all render_text "ok" end end that gives this error: ActiveRecord::StatementInvalid in Tipo_trasporti#index ERROR: relation "tipo_trasportis" does not exist : SELECT * FROM tipo_trasportis script/server:51 someone can help me? Thanks Enrico -- "The only thing necessary for the triumph of evil is for good men to do nothing" Edmund Burke
On 8 Mar 2005, at 16:18, Enrico Teotti wrote:> class Mouse < ActiveRecord::Base > table_name "mice" > endYou''re supposed to use class Mouse < ActiveRecord::Base def self.table_name() "mice" end end Guan
Then the documentation in ActiveRecord::Base table_name() needs to be updated, as this is where the example given below comes from. - Robert On Tue, 8 Mar 2005 16:24:18 +0100, Guan Yang <guan-Tn7NQuJrROJAfugRpC6u6w@public.gmane.org> wrote:> > On 8 Mar 2005, at 16:18, Enrico Teotti wrote: > > class Mouse < ActiveRecord::Base > > table_name "mice" > > end > > You''re supposed to use > > class Mouse < ActiveRecord::Base > def self.table_name() "mice" end > end > > Guan
> You''re supposed to use > > class Mouse < ActiveRecord::Base > def self.table_name() "mice" end > endYou can also use set_table_name :mice or table_name= :mice