Associations problem

Hi there!

I have a following models:

class Chart < ActiveRecord::Base
  belongs_to :chart_category
  belongs_to :gifi

  has_many :gl_transactions

class GlTransaction < ActiveRecord::Base
  belongs_to :chart
  belongs_to :general_ledger

class GeneralLedger < ActiveRecord::Base
  has_many :gl_transactions
  has_many :charts, :through => :gl_transactions

In general_ledger_controller I have a some standard find clause with

          counter = GeneralLedger.count( :order => order,
                      :conditions => [' = ?',params[:chart_id]],
                      :include => 'charts' )

By some mysterious reason it returns me a following message:

RuntimeError: ERROR C42804 Margument of WHERE must be type boolean, not type charts
Fparse_coerce.c L810
Rcoerce_to_boolean: SELECT COUNT(DISTINCT FROM general_ledgers
LEFT OUTER JOIN transactions ON transactions.general_ledger_id =
LEFT OUTER JOIN charts ON = transactions.chart_id WHERE (charts)

I cannot understand why Where clause was overwritten with :include data?

Can someone help me with this?

All the Best!

Nevermind, that was my mistake.

All the Best!

Sergey Kuznetsov wrote: