# Generating search conditions?

**URL:** <https://www.ruby-forum.com/t/generating-search-conditions/120591>\
**Category:** Rails\
**Created:** [November 18, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/generating-search-conditions/120591 "2007-11-18T23:21:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [November 18, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/generating-search-conditions/120591/1 "2007-11-18T23:21:38Z")

</div>

Could anyone tell me good options for generating search conditions.  
Specifically I have parameters based on time (today, yesterday, etc)  
and I want a private method in a model to generate a conditions  
statement.  
The only way I can think to do it is something like :

(pseudocode)  
def gen\_conditions(part)  
if part == “today”  
return “submitted at \< date”  
else if part ==“yesterday”  
return “submitted at \< date”  
end  
end

This would probably work, but I’m thinking there might be a better  
way. Thanks for any advice.

JB

---

<div class="post-metadata">

**Author:** ![Jables](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58956e/32.png) [@Jables](https://www.ruby-forum.com/u/Jables)\
**Post date:** [November 18, 2007, 11:55pm UTC](https://www.ruby-forum.com/t/generating-search-conditions/120591/2 "2007-11-18T23:55:00Z")

</div>

hi, i think “Chronic” is the library you’re looking for. check it at :  
[http://chronic.rubyforge.org/](http://chronic.rubyforge.org/)
