0
我已經在我的模型有多種HAS_ONE協會思考獅身人面像和多個HAS_ONE
class Invoice < ActiveRecord::Base
...
belongs_to :seller, :class_name => "Client", :foreign_key => "provider", :conditions => ['is_provider = ?', true]
belongs_to :customer, :class_name => "Client", :foreign_key => "receiver", :conditions => ['is_receiver = ?', true]
我試圖建立索引:
indexes [seller(:tbClientCode), seller(:tbClientLabel), seller(:tbClientName), seller(:tbClientNIP),
seller(:tbClientRegon), seller(:tbClientZip), seller(:tbClientCity), seller(:tbClientStreet),
seller(:tbClientHouseNr), seller(:tbClientHomeNr], :sortable => true, :as => :seller_fields
has [seller(:is_provider), seller(:is_receiver)], :sortable => true, :as => :seller_attributes
indexes [customer(:tbClientCode), customer(:tbClientLabel), customer(:tbClientName), customer(:tbClientNIP),
customer(:tbClientRegon), customer(:tbClientZip), customer(:tbClientCity), customer(:tbClientStreet),
customer(:tbClientHouseNr), customer(:tbClientHomeNr], :sortable => true), :as => :customer_fields
has [customer(:is_provider), customer(:is_receiver)], :sortable => true, :as => :customer_attributes
...然後一些錯誤發生
ERROR: index 'invoice_core': sql_range_query: ERROR: column reference "is_receiver" is ambiguous
LINE 1: ...tomers_invoices"."id" = "invoices"."receiver" AND is_receive...
更改語法從客戶(:tbClientName)到customer.tbClientName不是解決方案。
一些幫助,將不勝感激
謝謝!你的解決方案完美無缺 – zachar