1

I had the following in searchlogic:

Todo.contact_id_is(self.id).ascend_by_original_date.done_date_not_null.first

How would I do this in metawhere now that I am in Rails 3? In particular the not_null and the sorting?

Hello, I'm a little confused. When I look at the named scopes found in meta_search (instead of metawhere)...that's more of what I'm looking for...and now metasearch is being replaced with ransack....

What is the way to do chained searches with sql on my models in the way searchlogic made it so drop-dead easy?

...okay...now it looks like ransack is for forms, but queries on models is squeel? Checking that out....

Satchel
  • 16,414
  • 23
  • 106
  • 192

1 Answers1

0

It seems that metawhere doesn't have != operator it was added in sqeel so here is a possible workaround

Todo.where( { :contact_id => self.id} ).order( :original_date.asc ).where( '"todos"."done_date" NOT NULL' ).first
Bohdan
  • 8,298
  • 6
  • 41
  • 51
  • I see....I don't think contact_id_is works....? I get a method missing error.... – Satchel Sep 30 '11 at 15:27
  • wait, are you using sqeel instead, should I use sqeel? How would that help? – Satchel Oct 22 '11 at 03:21
  • I get an error, does Postgres not handle NULL? PGError: ERROR: syntax error at or near "NULL" LINE 1: ... AND "todos"."asset_id" = 1)) AND (todos.done_date NOT NULL) ^ : SELECT COUNT(*) FROM "todos" WHERE (("todos"."asset" = 'Email' AND "todos"."asset_id" = 1)) AND (todos.done_date NOT NULL) – Satchel Oct 22 '11 at 03:45
  • Postgres understands `NULL` but it seems that it uses `"todos"."done_date"` not `todos.done_date`. Try updated version, please. As I understood from documentation `Squeel` is an advanced version of `metawhere`. It has more operators. – Bohdan Oct 26 '11 at 07:11
  • gotcha, thanks....I used what you did with metawhere....I actually found that not_eq is the same as not equal – Satchel Oct 26 '11 at 14:35