title: Ruby on Rails: Model tell Controller that search query was invalid?
body: <p>When I get a search query, my model checks to make sure it's in the right format. If it's not, I want, instead of displaying the search results, to display a message saying "bad search format". How do I do this?</p>
  
  <p>Controller:</p>
  
  <pre><code>  def search
      @students = Student.super_search(params[:super_search])
  
     # if (INVALID_FLAG == true) ???
     #   make error message...   ???
       if (@students.present?)
         @students = @students.paginate(page: params[:page])
      end
    end
  </code></pre>
  
  <p>And my model:</p>
  
  <pre><code>  def self.super_search(super_search)
      if super_search =~ /MY_SPECIAL_REGEX/
        # get and return search results
      else
        # set INVALID_FLAG
      end
    end
  </code></pre>