Hi, I have some code on my development machine that is running fine. When I moved the whole rails env to another box, it seems all my activerecord objects have no attributes at all, though the database config is correct, and the necessary table is present. I''m using rails 0.12.1 on both debian boxes, same ruby version: ruby1.8_1.8.2-5_i386.deb. I have all ruby related packages installed, according to http://wiki.rubyonrails.com/rails/show/HowtoInstallCompleteRubyOnDebian. The only difference I found is postgresql 7.4.6-3 on development and 7.4.7-5 on the new problematic machine. Connection to the database is ok though For example I use the salted login gem, and I get this error: undefined method `login'' for #<User:0x40c41434 @new_record=true, @attributes={}> Extracted source (around line #21): 21: <%= text_field "user", "login", :size => 30 %><br/> I have tested with other ActiveRecord classes I have defined, and I get the same problem with them: all the class looks as if had no attribute defined, though they are in the database! When I try User.new(:login => "raphael") it complains there is no method login= Any one experienced the same? What should I modify to make it work? Thanks Raph
Raphael Bauduin <rblists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:> I have tested with other ActiveRecord classes I have defined, and I > get the same problem with them: all the class looks as if had no > attribute defined, though they are in the database!Are you certain your config/database.yml is correct. It kinda sounds like there is no database connection. AR gets all the attributes based on the db scheme. Can you look in your logs to see if the selects are there? Is it possible that you''re looking at the scheme in your development db, but you''re running from a production db that hasn''t been cloned? -- doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org
On 5/4/05, Doug Alcorn <doug-jGAhs73c5XxeoWH0uzbU5w@public.gmane.org> wrote:> Raphael Bauduin <rblists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > > > I have tested with other ActiveRecord classes I have defined, and I > > get the same problem with them: all the class looks as if had no > > attribute defined, though they are in the database! > > Are you certain your config/database.yml is correct. It kinda sounds > like there is no database connection. AR gets all the attributes > based on the db scheme. Can you look in your logs to see if the > selects are there? Is it possible that you''re looking at the scheme > in your development db, but you''re running from a production db that > hasn''t been cloned?I have corrected it by reloading the data in another database. It is really strange as the connection to the database happened correctly, but this query returned nothing: SELECT column_name, column_default, character_maximum_length, data_type FROM information_schema.columns WHERE table_catalog ''madb'' AND table_schema = ''public'' AND table_name = ''users''; I dropped the database ''madb'', created another database ''othername'', restored the dump in that new database, and adapted databases.yml and it then worked. I guess the problem came from the restore of the database. Somehow something went wrong and entries in information_schema.columns were not created. Raph