Hi,
I have a customer and conversation model. A conversation is between 2
customers.
Here is my association in customer.
has_many :conversations, :class_name => "Conversation", :order =>
'updated_at DESC', :finder_sql => 'SELECT * FROM conversations c WHERE
(c.started_by = #{id} OR c.with = #{id})' do
    def with(cust_id)
     all(:conditions => ["conversations.started_by = ? OR
conversations.with = ?", cust_id, cust_id])
    end
  end

Inside the association block I made a method which filters on the second
customer of the conversation.

But when I do:
myCustomer.conversations.with(someoneelseID)

I get the following error.

ActiveRecord::StatementInvalid (Mysql::Error: Operand should contain 1
column(s): SELECT * FROM `conversations` WHERE (conversations.started_by
= 1 OR conversations.with = 1) AND (SELECT * FROM conversations c WHERE
(c.started_by = 1 OR c.with = 1))  ORDER BY updated_at DESC)

How can i make Rails build a correct sql request?
Greg

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to