Hi. I'm attempting to return a result set which filters Pages by their 
active state and their start/end date. Whilst the code I have at the 
moment is doing this without problem, some of the Page items may not 
have an end date set and I can't see a way of conditionally doing the 
query so these are not excluded.

Perhaps showing some code will help explain better;

search_controller.rb

      @results = Page.multi_search(
        "active:(true)
        *:(#{params[:s]})
        search_start_date:( <= #{Time.now.strftime("%Y%m%d")} )
        search_end_date:( >= #{Time.now.strftime("%Y%m%d")} )",
        [],
        {:offset => @offset, :limit => @limit}
      )

Page.rb

  def search_start_date
    self.start_at.strftime("%Y%m%d") if self.start_at
  end

  def search_end_date
    self.end_at.strftime("%Y%m%d") if self.end_at
  end


The problem being that I can't figure out how to do the equivalent of:

        search_end_date:( IS NULL OR >= #{Time.now.strftime("%Y%m%d")} 
)",


Thanks for any help/advice,

Cam

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to