title: find ActiveRecord command in Rails does not work
body: <p>In the search function of my application, where a user can input a search text and pick a category (subject) from a dropdown. </p>
  
  <p>In the do_search action in my controller, I find the courses by doing <strong>Subject.find(params[:subject]).courses</strong> where <strong>params[:subject]</strong> is the <em>s_id</em> (subject ID) of each Subject ("1234-123", "4123-232", ...).</p>
  
  <p>When running the server, I tried searching but no result is found. I also checked it in the rails console but 0 matches as well.</p>
  
  <p>This is the code for the do_search action in my controller:</p>
  
  <pre><code>def do_search
      if params[:subject].blank? &amp;&amp; params[:search_text].blank?
        @courses = Course.all
      elsif !params[:subject].blank? &amp;&amp; !params[:search_text].blank?
        @courses = Subject.find(params[:subject]).courses.where("UPPER(name) LIKE ?", "%#{params[:search_text].upcase}%")
      elsif !params[:subject].blank? 
        @courses = Subject.find(params[:subject]).courses
      else
        @courses = Course.where("UPPER(name) LIKE ?", "%#{params[:search_text].upcase}%")
      end
      return @courses
  end
  </code></pre>
  
  <p>The schema: courses - subjects: many-to-many</p>
  
  <blockquote>
    <p>subjects</p>
    
    <blockquote>
      <ul>
      <li>s_id (the Subject ID): string</li>
      <li>name: string</li>
      </ul>
    </blockquote>
    
    <p>courses</p>
    
    <blockquote>
      <ul>
      <li>code: string</li>
      <li>name: string</li>
      </ul>
    </blockquote>
    
    <p>contains</p>
    
    <blockquote>
      <ul>
      <li>course_id: integer (primary key created by ActiveRecord for each course)</li>
      <li>subject_id: integer (primary key created by ActiveRecord for each subject)</li>
      </ul>
    </blockquote>
  </blockquote>