我有问题。我有模型用户:
class User < ActiveRecord::Base
end
从用户继承的模型承包商
class Contractor < User
has_many :contractorEs
has_many :customers
end
从 User 继承的模型 Customer
class Customer < User
belongs_to :contractor
has_many :customer_es
end
在我的客户表中,我有列“contractor_id”。然后我rails c
输入:
c = Contractor.first
c.customers.build
并unknown attribute: contractor_id
发生。然后我输入:
customer = Customer.new
并且有:
<Customer id: nil, first_name: nil, last_name: nil, address: nil, country: nil, zip: nil, city: nil, phone: nil, company_name: nil, signature: nil, type: "Customer", created_at: nil, updated_at: nil, v_token: nil, password_digest: nil, u_token: nil, email: nil, state: "new">
但contractor_id
列表中没有。如何解决?我正在使用 rails 4 和 ruby 2.0。