Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Search < ActiveRecord::Base
- belongs_to :searchable, :polymorphic => true
- # This will actually work now, no more
- # n + 1 query problems, yay!
- default_scope :include => :searchable
- def hash
- searchable_id.hash + searchable_type.hash
- end
- def eql?(result)
- searchable_type == result.searchable_type and
- searchable_id == result.searchable_id
- end
- # And view results can't be updated, so...
- def readonly?
- true
- end
- end
Add Comment
Please, Sign In to add comment