0

How can I write the activerecord statement,

Comments.where("attachment IS NOT NULL")

in DataMapper

ie., I want to execute "SELECT * FROM comments WHERE attachment IS NOT NULL; with DataMapper in rails.

Please help; I am not much familiar with DM!

Sayuj
  • 7,464
  • 13
  • 59
  • 76

1 Answers1

6

Using the old AR 2.3 syntax should work for you

Comment.all(:conditions => 'attachment IS NOT NULL')

Alternatively, you can use the not method available on symbols for DataMapper queries:

Comment.all(:attachment.not => nil)
PinnyM
  • 35,165
  • 3
  • 73
  • 81