Skip to content
Jun 3 11

MetaSearch struggle

by nick

TL;DR – MetaSearch doesn’t respond like you think it should when you try to use (named) scopes without registering with :search_methods first.

I ran across a strange issue with MetaSearch with a model I have:

class Order < ActiveRecord::Base
  scope :completed, {:conditions => "status='complete'"}
end

I was trying to do the following:

Order.search(:date_gte => Date.today - 14, :date_lt => Date.today + 1, :completed => true).

The resulting query looked like:

SELECT * FROM orders WHERE date < '2011-06-04'

My first thought was "MetaSearch does not support using multiple predicates per column. That's odd..." - but really it was that MetaSearch didn't completely finish creating all the wheres due to the use of the scope 'completed'. The fix was simply to call search_methods :completed. MetaSearch works as expected at that point.

It is important to say this is not an error with MetaSearch.

This gist should help too: https://gist.github.com/dbab58161d9a65cf5f1c. Add to config/initializers.

Apr 21 11

Music

by nick

Uploaded some new recordings. Email for the link.

Feb 10 11

Anyone out there?

by nick

If you read this – let me know. Send me an email, DM me on twitter, or something.

Feb 10 11

Twitter Updates for 2011-02-10

by nick
  • I will be the proud owner of a Blue Spark microphone pretty soon. Excited! Thanks @sweetwatersound. #

Powered by Twitter Tools

Feb 8 11

Twitter Updates for 2011-02-08

by nick
  • RT @scribblepotemus: I think we should sing some songs this week. ;) // yes please! Especially Saturday night. #

Powered by Twitter Tools