I've populated a hash with two different models. I then try to sort them like so:
@search_results = User.find(:all, :conditions => ['name LIKE ?', "%#{params[:query]}%"])
@search_results += Book.find(:all, :conditions => ['title LIKE ?', "%#{params[:query]}%"])
@search_results.sort! { |a,b| a.impressions_count <=> b.impressions_count }
This throws the following error:
comparison of User with Book failed
Both users and books have an integer-based impressions_count. Why can't I sort via this attribute? What other options do I have?