title: Multi find search in ruby with date
body: <p>I have created a multi find search, where I need to filter records by date / category / title. Searching by a category and/or title works, however, when date is typed it doesn't change anything (the results is the same like there was no date typed). I have no idea what else I could do to fix it, I am just a beginner in Ruby. Any idea?</p>
  
  <p>Model:</p>
  
  <pre><code> def self.multi_find(cat_id, search,  date_search)
      search_condition = "%" + search + "%"
      #date_condition =  date_search
  # test if cat_id is not blank
      if not cat_id.blank? 
          # assign the value of cat_id to a ‘scope’ named :cat 
          scope :cat, -&gt; { where('category_id = ?', cat_id) }
          # using the ‘scope’ cat find where a search string is like a title or an author’s name
          self.cat.where("title LIKE ? or event_date = ?", search_condition, date_search.to_date)
      else
    # find where a search string is like a title or an author’s name
          self.where("title LIKE ? or event_date = ?", search_condition, date_search.to_date) 
      end
  end
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>  def multi_find
  # call an Event class method, using two parameters; a category unique identifier and a search string (author or title)
  events = Event.multi_find(params[:cat_id], params[:search_string], params[:event_date_search])
  # use Kaminari pagination ...
  @events = Kaminari.paginate_array(events.order :title).page(params[:page]).per(6)
  # if no products have been found
  if @events.empty?
    # display a notice
    flash.now[:alert] = "No events found - so displaying all events"
    # then display all products
    @events = Event.order(:title).page(params[:page]).per(6)
  end 
  # use the index view
  render :action =&gt; "index" 
  end
  </code></pre>
  
  <p>The console outputs the SQL Query</p>
  
  <pre><code>  Event Load (0.0ms)  SELECT "events".* FROM "events" WHERE (category_id = '1') AND (title LIKE '%%' or event_date = '2018-02-14') ORDER BY "events"."title" ASC
  </code></pre>
  
  <p>View file:</p>
  
  <pre><code>&lt;%= form_tag my_path, :method=&gt;'post', :multipart =&gt; true do %&gt;
  </code></pre>
  
    
  
  <pre><code>&lt;%= select_tag ('cat_id'), 
          options_from_collection_for_select(@categories, :id, :cat_name, 0 ),
          :prompt =&gt; "Select a Category" %&gt;
  
  &lt;div class="datepicker"&gt; 
    &lt;% @event_date_format %&gt; 
    &lt;%= text_field_tag :event_date_search  %&gt;
  
  &lt;/div&gt;
  
  &lt;!-- Key word:--&gt;
      &lt;%= text_field_tag :search_string %&gt;
      &lt;%= submit_tag 'Search' %&gt;
  &lt;% end %&gt;
  </code></pre>