我有两个模型:
数据中心:
class Datacentre < ActiveRecord::Base
has_one :provider
end
和提供者:
class Provider < ActiveRecord::Base
has_many :datacentres
end
在数据中心表中,provider_id
当我尝试在视图中显示它时,我得到了这个:Mysql2::Error: Unknown column 'providers.datacentre_id' in 'where clause': SELECT 'providers'.* FROM 'providers' WHERE 'providers'.'datacentre_id' = 262 LIMIT 11
似乎它的反应相反?
看法:
- Datacentre.find(:all, :order => " name ASC, country ASC", :conditions => "").each do |c|
%tr
%td= c.name
%td= c.provider.name
%td= c.country
%td
= c.address
= c.postcode