Searching a model based on a filter on its association

Hi all,

I got association like the following in my rails app.
Class User < ActiveRecord::Base
has_one :profile
end

Class Profile < ActiveRecord::Base
establish_connection :some_other_db
belongs_to :user
end

I need to search users based on the age stored in the profile
I tried using the :joins option of find. but it seems it works only on
tables in the same db.

Is there a way i can tell (:joins) to join a table from another db? Or
is
there some other better way in which this could be achieved?


Sahil D.

Sahil D. wrote:

I need to search users based on the age stored in the profile
I tried using the :joins option of find. but it seems it works only on
tables in the same db.

But of course.

So search the Profiles, get your list of user_id’s that match the
criteria, then select the Users.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs