Converting to datetime object is an excellent idea.  Thanks Jarin!

On Feb 20, 12:02 am, Jarin Udom <ja...@robotmo.de> wrote:
> For that particular search, you'll have to build your own search
> queries. The only other option is to load all records into memory and
> filter by the age instance method, but of course you don't want to do
> that.
>
> Searchlogic will still make the search easier though. You can convert
> the age from an integer into a datetime object and use it in a
> Searchlogic search like so:
>
> age = 29
>
> User.birthdate_greater_than(age.years.ago).birthdate_less_than((age -
> 1).years.ago).all
>
> Hope this helps!
>
> Jarin Udom
> Robot Mode LLC
>
> On Feb 19, 10:30 pm, Ease Bus <ease...@gmail.com> wrote:
>
> > Can I use something like searchlogic to search for objects based on
> > the return values of instance methods?  E.g., I'd like to search for
> > users of a certain "age" but age is not a column, it's an instance
> > method, returning the age value calculated from the birthdate, which
> > is a column.
>
> > Is there a quick way like searchlogic to do this or do I have to build
> > my own search queries?   Thanks.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to