Lurlay, Patrick
2006-Aug-08 03:14 UTC
[Rails] Error is: Couldn''t find Producttype without an ID
I am at a lost for what is going on here-------I have a producttypes and categories table. prodtype_id is a foreign key in categories table that references producttypes table. Below is how I am tyying to display it and get the above error. Any suggestion </p> <b>Product type:</b><br/> <select name="Category[prodtype_id]"> <% @producttype.each do |producttype| %> <option value="<%= producttype.id %>"> <%= producttype.producttype_name %> </option> <% end %> </select> </p> Error is: Couldn''t find Producttype without an ID Tables: class CreateProducttypes < ActiveRecord::Migration def self.up create_table :producttypes do |t| t.column :name, :string t.column :created_at, :datetime t.column :updated_on, :datetime end end def self.down drop_table :producttypes end End class CreateCategories < ActiveRecord::Migration def self.up create_table :categories do |t| t.column :name, :string t.column :prodtype_id, :int t.column :description, :string t.column :created_at, :datetime t.column :updated_on, :datetime end end def self.down drop_table :categories end end