Polymorphic challenge

Hello guys,

I have 2 classes (I pasted small part of them here);

class Shop < ActiveRecord::Base
has_many :items, :as=> :itemable

protected
def self.paying_scope
with_scope(:find => {:conditions => ‘expires_on > NOW()’, :include
=> [:address]}) do
yield
end
end
end

class Item < ActiveRecord::Base
belongs_to :itemable, :polymorphic => true
end

Shops has expires_on field which I check if they can be shown or not
during searches => NO PROBLEM

I need to do same think for items, if a shop subscription (=expires_on)
is expired then I wanna exclude that item from search.

What is the elegant way to solve it?

Thanks in advance

PS: I use http://rubyforge.org/projects/ez-where/ for my searches.

Gokhan

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