Named scope with has many

Having a problem getting my head round a named_scope problem

I have the following:

class Event < ActiveRecord::Base   has_many :event_alerts end

class EventAlert < ActiveRecord::Base    belongs_to :event end

I want to create a named scope that returns only those events that have event alerts.

But I just can't seem to get my head around it. This is Rails 2.3 if that is of importance.

Depending on the db you’re using, an EXISTS on the :where clause should do the trick.

instead of named scopes use class methods

http://www.railway.at/2010/03/09/named-scopes-are-dead/

Radhames Brito wrote in post #956904:

instead of named scopes use class methods

Named Scopes Are Dead | railway

That article applies only to Rails 3. The OP said he was using Rails 2.3. Therefore, your advice is irrelevant.

Please read all details before giving advice.

Best,

not irrelevant as he can use class methods anyway and is are more flexible, i posted the link with general info on scopes as you can see the author praises scopes in rails 2 in the first part of the article and later explains the good and bad about them along with some guide on how to use class methods.

Radhames Brito wrote in post #956940: