Monday, December 6, 2010

Rails: Couldn't find Product without an ID

Couldn't find Product without an ID

Couldn't find tablename without an ID

A possible reason is that the tablename, Product doesn't have a primary_key. So fix this by editing the model and add:

class Product < ActiveRecord::Base has_many :items, :as => :item_id

set_primary_key :item_id

end

No comments: