Rails: HasManyThroughAssociationNotFoundError

Habe ich Probleme mit dem Erhalt einer has_many through Verein zu arbeiten.

Ich bekomme immer diese exception:

Article.find(1).warehouses.build
ActiveRecord::HasManyThroughAssociationNotFoundError: Could not find the association :entries in model Article

Diesen Modellen beteiligt:

class Article < ActiveRecord::Base
  has_many :warehouses, :through => :entries
end

class Warehouse < ActiveRecord::Base
  has_many :articles, :through => :entries
end

class Entry < ActiveRecord::Base
  belongs_to :article
  belongs_to :warehouse
end

Und das ist mein schema:

create_table "articles", :force => true do |t|
  t.string   "article_nr"
  t.string   "name"
  t.integer  "amount"
  t.string   "warehouse_nr"
  t.datetime "created_at"
  t.datetime "updated_at"
  t.integer  "unit"
end

create_table "entries", :force => true do |t|
  t.integer "warehouse_id"
  t.integer "article_id"
  t.integer "amount"
end

create_table "warehouses", :force => true do |t|
  t.string   "warehouse_nr"
  t.string   "name"
  t.integer  "utilization"
  t.datetime "created_at"
  t.datetime "updated_at"
end

InformationsquelleAutor der Frage | 2009-06-03

Schreibe einen Kommentar