title: Rails: acts_as_taggable_on, getting errors when attempting to find articles by tag
body: <p>I have been following along with a RailsCasts episode, and am trying to make articles taggable. Then I want to make tags clickable on articles show.html page, so that users can find other related articles. I am using Rails 4. However, I have been getting the following error: </p>
  
  <pre><code>ActiveRecord::RecordNotFound in ArticlesController#show
  
  Couldn't find Article without an ID
  
  Extracted source (around line #43):
  
  def show 
    @article = Article.find(params[:id])
  end
  </code></pre>
  
  <p>I then tried to make the following changes, which I observed after looking at the RailsCast code:</p>
  
  <p><strong>articles_controller.rb</strong></p>
  
  <pre><code>[...]
      def show  
          if params[:tag]
            @articles = Article.tagged_with(params[:tag])
          else
            @article = Article.find(params[:id])
          end
      end
  </code></pre>
  
  <p>Which gave me the error upon clicking a tag on a working show page:</p>
  
  <p><strong><a href="http://localhost:x000/tags/pizza" rel="nofollow noreferrer">http://localhost:x000/tags/pizza</a></strong></p>
  
  <pre><code>NoMethodError in Articles#show
  undefined method 'title' for nil:NilClass
  
  &lt;div id="article-title"&gt;
    &lt;h1&gt;
     &lt;p&gt;
      &lt;%= @article.title %&gt;&lt;/span&gt;
     &lt;/p&gt;
    &lt;/h1&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Which seems odd to me, since the title method works just fine otherwise. Everything else works on the site, the tags save and can be edited in the articles edit page, but finding all articles with a specific tag isn't working. </p>
  
  <p>===
  Relevant code areas:</p>
  
  <p><strong>_form.html</strong></p>
  
  <pre><code>&lt;p&gt;
      &lt;%= f.label :keyword_Tags %&gt;&lt;br/&gt;
      &lt;%= f.text_field :tag_list %&gt; &lt;span class="gray-text"&gt;&lt;em&gt;Separated by commas; single tag has no spaces, only-dashes &lt;/em&gt;&lt;/span&gt;
    &lt;/p&gt;
  </code></pre>
  
  <p><strong>routes.rb</strong></p>
  
  <pre><code>Network::Application.routes.draw do
    resources :libraries
  
    get "libraries/show"
    devise_for :authors, :controllers =&gt; {:registrations =&gt; "authors/registrations"}
  
    get 'tags/:tag', to: 'articles#show', as: :tag 
  
    devise_scope :author do
      get 'signup', to: 'devise/registrations#new' 
      get 'signin', to: 'devise/sessions#new' 
      # get 'logout', to: 'devise/sessions#destroy' 
    end
  
    resources :relationships, only: [:create, :destroy]
  
    get "landing_page/index"
    # The priority is based upon order of creation: first created -&gt; highest priority.
    # See how all your routes lay out with "rake routes".
    resources :articles do
      resources :comments
    end
    # You can have the root of your site routed with "root"
    root 'landing_page#index'
    get '/:id', to: 'libraries#show'
  end
  </code></pre>
  
  <p><strong>article.rb</strong></p>
  
  <pre><code> class Article &lt; ActiveRecord::Base
      has_many :comments, dependent: :destroy
      belongs_to :author 
      acts_as_taggable
      acts_as_taggable_on :tag_list
  
      validates :title, presence: true,
                      length: { minimum: 5 }
    validates :text, presence: true,
                                   length: { minimum: 2 }
      validates :article_start, presence: true,
                                          length: {minimum: 10}
  
  end
  </code></pre>
  
  <p><strong>[num]_create_articles.rb</strong></p>
  
  <pre><code>class CreateArticles &lt; ActiveRecord::Migration
    def change
      create_table :articles do |t|
        t.string :title
        t.time :era
        t.string :chapter
        t.date :article_start
        t.text :text
        t.string :tag_list
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>class ArticlesController &lt; ApplicationController
  before_filter :authenticate_author!, only: [:create, :new, :edit, :update, :destroy]
  #added destroy to above, not in Treebook
  
  def index
      @articles = Article.all 
  end
  
  def new # diff between new and create?
      @article = Article.new
  end
  
  def create 
      @article = Article.new(article_params)
  
      #respond_to do|format|
  
      if @article.save
          redirect_to @article 
      else
          render 'new'
  
      end
  end
  #end #for respond_to; noticed in "What is a join table"
  
  def show #show, being an action
      @article = Article.find(params[:id])
  
  end
  
  
  def edit
      @article = Article.find(params[:id])
  end
  
  def update
      @article = Article.find(params[:id])
  
      if @article.update(article_params)
          redirect_to @article
      else
          render 'edit'
      end
  end
  
  def destroy
      @article = Article.find(params[:id])
  
      @article.destroy
  
      redirect_to articles_path
  end
  
  
  
  private
      def article_params
          params.require(:article).permit(:title, :text, :author_id, :article_start, :era, :chapter, :address, :tag_list)
      end
  </code></pre>
  
  <p>end</p>
  
  <p><strong>Request</strong></p>
  
  <pre><code>Parameters:
  
  {"tag"=&gt;"open"}
  </code></pre>