# Using an AR Model to Specify and Store Complex Searches

**URL:** <https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024>\
**Category:** Rails\
**Created:** [May 13, 2007, 2:58am UTC](https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024 "2007-05-13T02:58:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasil003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@dasil003](https://www.ruby-forum.com/u/dasil003)\
**Post date:** [May 13, 2007, 2:58am UTC](https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024/1 "2007-05-13T02:58:40Z")

</div>

For a recent project I’ve had to create very complex search forms that  
were core to the application. Because I wanted the ability to save  
searches I decide that the search itself should be represented as a  
model, but once I got done I really liked the solution. I’m looking  
to turn a lot of the boilerplate into a plugin, but I want feedback  
first to see how other people are tackling the problem. My writeup is  
at  
[http://darwinweb.net/article/Implementing\_Advanced\_Search\_In\_Rails\_Using\_Search\_Models](http://darwinweb.net/article/Implementing_Advanced_Search_In_Rails_Using_Search_Models)

I welcome any feedback.

---

<div class="post-metadata">

**Author:** ![dasil003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@dasil003](https://www.ruby-forum.com/u/dasil003)\
**Post date:** [May 13, 2007, 2:26pm UTC](https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024/2 "2007-05-13T14:26:31Z")

</div>

Darwin,  
I went to your link and found a long list of links, NONE describing  
what you’re talking about?  
I am very interested in learning and helping you with this technique  
as I can see many places it’s needed.  
David

---

<div class="post-metadata">

**Author:** ![dasil003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@dasil003](https://www.ruby-forum.com/u/dasil003)\
**Post date:** [May 13, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024/3 "2007-05-13T18:16:52Z")

</div>

It’s right there! That’s a direct link to the article. The sidebar  
links are old articles.

---

<div class="post-metadata">

**Author:** ![dasil003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@dasil003](https://www.ruby-forum.com/u/dasil003)\
**Post date:** [May 14, 2007, 2:58pm UTC](https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024/4 "2007-05-14T14:58:11Z")

</div>

Darwin, I have much ‘egg on my face’ this morning and appreciate your  
patience in directing me to your article. I left a comment there and a  
‘Thank you’ and wish to extend an offer to help ‘digest’ this  
brilliant approach to the community. I see the HUGE hole in Rails as  
it’s end user query options and feel you are the best thing for an  
Enterprise solution.  
David

---

<div class="post-metadata">

**Author:** ![dasil003](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@dasil003](https://www.ruby-forum.com/u/dasil003)\
**Post date:** [May 14, 2007, 8:01pm UTC](https://www.ruby-forum.com/t/using-an-ar-model-to-specify-and-store-complex-searches/104024/5 "2007-05-14T20:01:43Z")

</div>

Thanks for the kind words. My blog is extremely basic and definitely  
needs some interface work. Your comment did not come through,  
probably because you have to Preview first in order to Save.

I still have quite a bit of work to bring this up to the level of  
other Rails plugins I use every day. I’m surprised that I haven’t  
been able to find anything out there like this, but I’m sure there’s a  
lot of experience and patterns that smarter people than me are using  
in this area. Once I finish the plugin I will post another message  
here and hopefully will be able to garner some attention and provide a  
robust solution.

I want to publically acknowledge Zach D. for creating  
ActiveRecord::Extensions which makes hash-based conditions so much  
more powerful.
