내 where 절에 약간 문제가 있습니다.레일즈 3 where() 절을 사용하여
PurchasePosition.where(:purchase_order_id => 996).where('sum(pallet_purchase_position_assignments.quantity) < purchase_positions.quantity').includes(:pallet_purchase_position_assignments)
내 모델 :
class PurchasePosition < ActiveRecord::Base
has_many :pallet_purchase_position_assignments, :class_name => "PalletPurchasePositionAssignment"
has_many :pallets, :class_name => "Pallet", :through => :pallet_purchase_position_assignments
end
class Pallet < ActiveRecord::Base
has_many :pallet_purchase_position_assignments, :class_name => "PalletPurchasePositionAssignment"
has_many :purchase_positions, :class_name => "PurchasePosition", :through => :pallet_purchase_position_assignments
end
class PalletPurchasePositionAssignment < ActiveRecord::Base
belongs_to :pallet, :class_name => "Pallet", :foreign_key => "pallet_id"
belongs_to :purchase_position, :class_name => "PurchasePosition", :foreign_key => "purchase_position_id"
end
내가 할 모든 내가 절대적으로 아무 생각이없는 MySQL의 오류
ActiveRecord::StatementInvalid: Mysql2::Error: Invalid use of group function
내 오류가있다 : -/
누군가가 있습니까 내 문제에 대한 해결책?
마이클
숀, 덕분에 많은 도움;) – sufu90