I have a post and comment model. A post has many comments. What I want to do is have a query that checks for posts where the last comment description is empty.
class Post < ActiveRecord::Base
has_many :comments
end
class Comment < ActiveRecord::Base
belongs_to :post
end
Without sql, this would look like this:
Post.all.select { |p| p.comments.last.description == "" }
N.B: This is a rails 3.2 application. where.not
does not work in this case