title: Search to return a single record from a list with duplicate entries - Ruby Rails
body: <p>I am trying to return a search from a table called 'showings' that has a field called 'show_date' with duplicate date entries and a field called 'film_id' (which belongs to the primary key 'id' in a table called 'films').</p>
  
  <p>I would like to search for any film that has a specific showing date (for example today) so that only one record is returned per film (because each film has more than one showing with the same date in the showings table).</p>
  
  <p>My search view looks like:</p>
  
  <pre><code>&lt;!-- app\views\_search.html.erb --&gt;
  
  &lt;%= form_tag my_path do %&gt;
    &lt;% date = Date.today %&gt;
    &lt;%= hidden_field_tag :search_string, date.strftime("%F") %&gt; 
  
    &lt;div class="tab-content"&gt;
      &lt;%= submit_tag "What's on", class: "btn" %&gt;
    &lt;/div&gt;
  
  &lt;% end %&gt;
  </code></pre>
  
  <p>My controller looks like:</p>
  
  <pre><code>def search
      @films = Film.date_search(params[:search_string])
      else if @films.empty?
          flash.now[:alert] = "There are no films showing with that date - Showing all films."
          @films = Film.all.order :title
      end
      render :action =&gt; "index"
  end
  </code></pre>
  
  <p>My film model looks like:</p>
  
  <pre><code>def self.date_search(search_string)
      film = Showing.where("show_date = ?", search_string).pluck(:film_id)
  end
  </code></pre>
  
  <p>I believe my main issue is with the film model code above since I am unsure how to retrun multiple unique film records with only one show_date per record. Any help would be much appreciated.</p>