/ Published in: Ruby
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def self.find_with_all_actors(*actors) return [] if actors.empty? actors = actors.flatten find(:all, :readonly => false, :joins => "INNER JOIN appearances a ON movies.id = a.movie_id", :conditions => "a.actor_id IN (#{actors.map(&:id).join(', ')})", :group => "movies.id HAVING COUNT(movies.id) = #{actors.size}") end