Forum: Ruby on Rails Problem with set_table_name

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sarathy .. (Guest)
on 2009-02-25 15:22
Dear friends,
       I ran the following in my console.Assume I already have the
postgresql connection .

>> class D < ActiveRecord::Base
>> end
=> nil

>> D.set_table_name "users"
=> nil
>> D.column_names
=> ["id", "name", "fname", "lname", "password", "addr1", "addr2",
"city", "state", "email", "created", "gender"]

>> D.reset_table_name
=> "ds"
>> D.set_table_name "orders"
=> nil
>> D.column_names
=> ["id", "name", "fname", "lname", "password", "addr1", "addr2",
"city", "state", "email", "created", "gender"]

>> D.table_name
=> "orders"

   Though I have different columns in "orders" table ,I get the same
column_names for "orders" table .

Please help me.




Regards,
Sarathy
Frederick C. (Guest)
on 2009-02-25 16:13
(Received via mailing list)
On 25 Feb 2009, at 13:22, Sarathy .n wrote:

>
>>> D.table_name
> => "orders"
>
>   Though I have different columns in "orders" table ,I get the same
> column_names for "orders" table .
>
ActiveRecord caches the column information - you should probably call
reset_column_information after changing the table name

Fred
This topic is locked and can not be replied to.