I can't understand why this code works:
@ads = Ads.find(
:all,
:joins => "INNER JOIN ad_users u ON u.ad_users_id=ads.ad_users_id"
)
and this one doesn't:
@ads = Ads.find(
:all,
:joins => :AdUsers
)
my classes are:
class Ads < ActiveRecord::Base
set_primary_key :ads_id
belongs_to :AdUsers
end
and
class AdUsers < ActiveRecord::Base
set_primary_key :ad_users_id
has_many :Ads
end
I use a sqlite database. The sql generated for the join is:
SELECT "ads".* FROM "ads" INNER JOIN "ad_users" ON "ad_users"."ad_users_id" IS NUL
can anyone help me? I know this is not a blocker, but I don't want to write the join SQL if I don't have to.
thanks