I am trying to retrieve an activerecord object from my db. My models are
class User < ActiveRecord::Base belongs_to :account has_many :domains, :thr
If you're using Rails 3.x, the following code would get the query result:
User.where(:username => "Paul").includes(:domains).where("domains.name" => "paul-domain").limit(1)
To inspect what happen, you can append .to_sql to above code.
.to_sql
If you're using Rails 2.x, you'd better write the raw sql query.