I'm new to Rails and trying to understand associating entities.
I have three entities right now: Users, Companies, and Productlines.
company.rb:
class Company < ActiveRecord::Base
has_many :users
has_many :productlines
end
user.rb:
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
belongs_to :company
end
productline.rb:
class Productline < ActiveRecord::Base
belongs_to :company
end
I've done the migration scrips to associate them, however when I click into a Company on Rails Admin, I'm getting this:
SQLite3::SQLException: no such column: productlines.company_id: SELECT "productlines".* FROM "productlines" WHERE "productlines"."company_id" = ?
Extracted source (around line #91):
#
def prepare sql
stmt = SQLite3::Statement.new( self, sql )
return stmt unless block_given?
begin
Edit: Here is my migration:
class AddProductlineIdToCompanies < ActiveRecord::Migration
def change
add_column :companies, :productline_id, :integer
add_index :companies, :productline_id
end
end
company_idis missing in theproductlinestable - gabrielhilalrake db:migrateafter adding that migration? - David Hoelzer