No, I don't work in NYC, DC, or the valley, and I'm cool with that.
Version 0.3.0 of MetaSearch is out. Changes since the last time I posted include additional view helpers for gathering array input, the addition of unit tests, and easier attribute and association exclusion that honors excluded attributes through associations.
If you need to get an array into your where, and you don’t care about parameter order, you might choose to use a select or collection_select with multiple selection enabled, but everyone hates multiple selection boxes. MetaSearch adds a couple of additional helpers, check_boxes and collection_check_boxes to handle multiple selections in a more visually appealing manner. They can be called with or without a block, so something like this is possible when you want additional formatting around your check boxes:
<h3>How many heads?</h3>
<ul>
<% f.check_boxes :number_of_heads_in,
[['One', 1], ['Two', 2], ['Three', 3]],
:class => 'checkboxy' do |c| %>
<li>
<%= c[:check_box] %>
<%= c[:label] %>
</li>
<% end %>
</ul>You can read more in the rdocs.
If you’d like to prevent certain associations or attributes from being searchable, you can control this inside your models:
class Article < ActiveRecord::Base metasearch_exclude_attr :some_private_data, :another_private_column metasearch_exclude_assoc :an_association_that_should_not_be_searched, :and_another end
You get the idea. Excluded attributes on a model will be honored across associations, so if an Article has_many :comments and the Comment model looks something like this:
class Comment < ActiveRecord::Base validates_presence_of :user_id, :body metasearch_exclude_attr :user_id end
Then your call to Article.search will allow :comments_body_contains but not :comments_user_id_equals to be passed.
I'm Ernie Miller. But then, you probably knew that by looking at the page title, or the URL. I'm a Ruby programmer in Louisville, Kentucky. This blog used to be called "metautonomo.us", which I thought was kind of clever, but nobody, including me, could type it. Lesson learned.

Pingback: metautonomo.us » Blog Archive » MetaSearch, Object-based searching for Rails 3