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’[email protected]’)
/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:inexecute’
/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:ininsert_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:ininsert_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:ineach’
/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:intransaction’
/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:indisable_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:insilence’
/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:ineach’
/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:inexecute’
/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:inexecute’
/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:insynchronize’
/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:ininvoke’
/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:intop_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:intop_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:intop_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:instandard_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:inload’
/usr/bin/rake:19

I have this two fixtures:

admin_users.yml

admin:
login: admin
email: [email protected]
salt: eca03dde78af4419efb984b1c1ebce8ab9446ac0
crypted_password: bc907667ec4a1d826f3c0cbda775083af9a8d328 # admin
admin_roles: admin_role

editor:
login: editor
email: [email protected]
salt: 50e776d5c45cadb66b8f85d7f4414d56deb1a025
crypted_password: b67d504587dbefa525cfd1c4e6af294a068fa095 # editor
admin_roles: editor_role

moderador:
login: moderador
email: [email protected]
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

Jorge,

Did you ever find out what was going on with this? I’m having the
same error now. What’s weird is that it works fine in MySQL.

Sean

On Jan 22, 11:59 am, Jorge D. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs