class Contractor < User
has_many :contractorEs
has_many :customers
end
class Customer < User
belongs_to :contractor
has_many :customerEs
end
class AddContractorIdToCustomers < ActiveRecord::Migration
def change
add_column :customers, :contractor_id, :integer
end
end
c = Contractor.first
c.customers.build
ActiveRecord::UnknownAttributeError: unknown attribute: contractor_id
<customer id: nil, first_name: last_name: address: country: zip: city: phone: company_name: signature: type: "customer", created_at: updated_at: v_token: password_digest: u_token: email: state: "new">
</customer>
def contractor_params
params.require(:contractor).permit(:contractior_id)
end
attr_accessible :contractor_id
has_many :contractorEs
has_many :contractors
Find more questions by tags RubyActive RecordRuby on Rails