Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有很多属于Movielike的照片Movie.photos。有些电影有照片,有些则没有。
Movie
Movie.photos
如何轻松找到所有没有照片的电影?
将此方法放入您的电影模型中
def self.no_photos Movie.all.reject{|movie| movie.photos} end
你可以这样使用它。
movies_with_no_photos = Movie.no_photos