title: Rails - uninitialized constant ArticlesController::Article
body: <p>Please help, not sure what I'm doing wrong at all. I'm just trying to make a simple search form, and I'm guessing I just have an error in my routes maybe, but I'm not that strong at debugging as I'm fairly new.</p>
  
  <p>The error is - </p>
  
  <blockquote>
    <p>uninitialized constant ArticlesController::Article</p>
  </blockquote>
  
  <p>routes.rb - </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
    &lt;title&gt;Simple Search Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;!-- When submit the form, the view rendered will be the index view of our articles resource --&gt;
    &lt;%= form_tag(articles_path, :method =&gt; "get", class: "navbar-form", id: "search-form") do %&gt;
      &lt;div class="input-append"&gt;
        &lt;%= text_field_tag :search, params[:search], class: "span2", placeholder: "Search Articles" %&gt;
        &lt;!-- In order to have the "search" icon int the button, we need to use plain HTML instead 
             of using a Rails form helper --&gt;
        &lt;button class="btn" type="submit"&gt;&lt;i class="icon-search"&gt;&lt;/i&gt;&lt;/button&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
    &lt;%= yield %&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>articles.rb - </p>
  
  <pre><code>def Article &lt; ActiveRecord::Base
    attr_accessible :title, :content
  
    validates :title, presence: true, uniqueness: true
    validates :content, presence: true
  
    # It returns the articles whose titles contain one or more words that form the query
    def self.search(query)
      # where(:title, query) -&gt; This would return an exact match of the query
      where("title like ?", "%#{query}%") 
    end
  end
  </code></pre>
  
  <p>articles_controller.rb ***THIS IS WHERE THE ERROR IS**** It highlights "@articles = Article.order("create_at DESC")"</p>
  
  <pre><code>class ArticlesController &lt; ApplicationController
    def index
      if params[:search]
        @articles = Article.search(params[:search]).order("created_at DESC")
      else
        **@articles = Article.order("created_at DESC")**
      end
    end
  end
  </code></pre>
  
  <p>index.html.erb -</p>
  
  <pre><code>    &lt;% @articles.each do |article| %&gt;
    &lt;div class="article"&gt;
      &lt;h1 class="article-title"&gt;&lt;%= link_to article.title, article %&gt;&lt;/h1&gt;
      &lt;p class="article-content"&gt;&lt;%= article.content %&gt;&lt;/p&gt;
    &lt;/div&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>application.html.erb - </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;head&gt;
    &lt;title&gt;Simple Search Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;!-- When submit the form, the view rendered will be the index view of our articles resource --&gt;
    &lt;%= form_tag(articles_path, :method =&gt; "get", class: "navbar-form", id: "search-form") do %&gt;
      &lt;div class="input-append"&gt;
        &lt;%= text_field_tag :search, params[:search], class: "span2", placeholder: "Search Articles" %&gt;
        &lt;!-- In order to have the "search" icon int the button, we need to use plain HTML instead 
             of using a Rails form helper --&gt;
        &lt;button class="btn" type="submit"&gt;&lt;i class="icon-search"&gt;&lt;/i&gt;&lt;/button&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
    &lt;%= yield %&gt;
  &lt;/body&gt;
  </code></pre>