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
<% @producttype.each do |producttype| %> <%= producttype.producttype_name %> <% end %>
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