Jorge Dias
2008-Jan-22 15:59 UTC
Can''t load fixtures into db with has_and_belongs_to_many
Hi, I''ve been having some problem with the new features in fixtures included in rails 2.0.2. The problem I''m having is although my test run fine, i''m unable to import them into the db using rake db:fixtures:load This is the error i''m getting: rake aborted! PGError: ERROR: column "admin_roles" of relation "admin_users" does not exist LINE 1: ...ERT INTO admin_users ("salt", "crypted_password", "admin_rol... ^ : INSERT INTO admin_users ("salt", "crypted_password", "admin_roles", "login", "email") VALUES (E''eca03dde78af4419efb984b1c1ebce8ab9446ac0'', E''bc907667ec4a1d826f3c0cbda775083af9a8d328'', E''admin_role'', E''admin'', E''admin-2FcWmJISPqVWk0Htik3J/w@public.gmane.org'') /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:407:in `execute'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:140:in `insert_fixture'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:633:in `insert_fixtures'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:570:in `each'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:570:in `insert_fixtures'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:516:in `create_fixtures'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:516:in `each'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:516:in `create_fixtures'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:514:in `create_fixtures'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/postgresql_adapter.rb:374:in `disable_referential_integrity'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:505:in `create_fixtures'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1198:in `silence'' /usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/fixtures.rb:504:in `create_fixtures'' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:157 /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:156:in `each'' /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:156 /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run'' /usr/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/bin/rake:19:in `load'' /usr/bin/rake:19 I have this two fixtures: admin_users.yml admin: login: admin email: admin-2FcWmJISPqVWk0Htik3J/w@public.gmane.org salt: eca03dde78af4419efb984b1c1ebce8ab9446ac0 crypted_password: bc907667ec4a1d826f3c0cbda775083af9a8d328 # admin admin_roles: admin_role editor: login: editor email: editor-2FcWmJISPqVWk0Htik3J/w@public.gmane.org salt: 50e776d5c45cadb66b8f85d7f4414d56deb1a025 crypted_password: b67d504587dbefa525cfd1c4e6af294a068fa095 # editor admin_roles: editor_role moderador: login: moderador email: moderador-2FcWmJISPqVWk0Htik3J/w@public.gmane.org salt: 90d48b947ea3b92b117c106773745cf04b2aa892 crypted_password: bc907667ec4a1d826f3c0cbda775083af9a8d328 # moderador # activation_code: adminscode # only if you''re activating new signups admin_roles: moderador_role -------- admin_roles.yml admin_role: name: admin editor_role: name: editor moderador_role: name: moderador ------------- The user model habtm roles, like this: class Admin::User < ActiveRecord::Base set_table_name ''admin_users'' # --------------------------------------- # The following code has been generated by role_requirement. # You may wish to modify it to suit your need has_and_belongs_to_many :admin_roles, :class_name => ''Admin::Role'', :join_table => "admin_roles_admin_users", :foreign_key => "admin_user_id", :association_foreign_key => "admin_role_id" ...... ---------------- Does anybody know what am I doing wrong? Using postgresql, and rails 2.0.2 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---