Problems with ActiveRecord assoc
Posted
by ciss
on Stack Overflow
See other posts from Stack Overflow
or by ciss
Published on 2010-05-20T16:27:13Z
Indexed on
2010/05/20
16:30 UTC
Read the original article
Hit count: 168
ruby-on-rails
Hello again, so i write my e-commerce shop cms and have some strange error:
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'id' in 'where clause': DELETE FROM `properties` WHERE `id` = NULL
so, i have three models
Items:
class Item < ActiveRecord::Base
has_many :properties, :dependent => :destroy
has_many :types, :through => :property
end
Type:
class Type < ActiveRecord::Base
has_many :properties, :dependent => :destroy
end
Properties:
class Property < ActiveRecord::Base
belongs_to :item
belongs_to :type
end
So, all is okay, but when i try to item.destroy() i have error =(
This is my test code:
test "should destroy associated properties" do
item = Item.create(:name => "Jeans")
type = Type.create(:key => "color")
property = Property.new
property.item = item
property.type = type
property.save
item.destroy()
end
© Stack Overflow or respective owner