title: ActiveRecord::RecordNotFound Couldn't find Recipe with id=index
body: <p>I am working on a Rails application, but came across the following error message.</p>
  
  <pre><code>ActiveRecord::RecordNotFound in RecipesController#show
  
  Couldn't find recipe with id=index
  
  Extracted source (around line #8)
  
  def show
    @recipe = Recipe.find(params[:id]) # This line is highlighted in pink
  end
  </code></pre>
  
  <p>I believe this has to do with my routes. The url to my index page is localhost:3000/games/index (I'm calling the index action on my recipes controller. I created that action through resources :recipe creating seven restful routes including index.) However, when I access it, ROR thinks I'm accessing a game with id of index, through the show route. The truth is I would like to set my index page to localhost:3000/recipes. I don't want the index at the end.</p>
  
  <p>Here is my RecipesController</p>
  
  <pre><code>class RecipesController &lt; ApplicationController
  
    def index
      @recipe = Recipe.all
    end
  
    def show
      @recipe = recipe.find(params[:id])
    end
  
    def new
      @recipe = Recipe.new
    end
  
    def create
      @recipe = Recipe.new(params[:id])
      if @recipe.save
        redirect_to @recipe
      else
        render 'new'
      end
    end
  
    def edit
    end
  
    def update
    end
  
    def destroy
    end
  
  end
  </code></pre>
  
  <p>As you can see, I defined the 7 common RESTful routes and have finished 4 of them.</p>
  
  <p>Here is my routes.rb file</p>
  
  <pre><code>Recipes::Application.routes.draw do
    resources :recipes
  end
  </code></pre>
  
  <p>By declaring resources :recipes, I created 7 routes without having to declare them on multiple lines.</p>
  
  <p>Here is the result of rake routes</p>
  
  <pre><code>Prefix     Verb   URI Pattern               Controller#Action
  recipes      GET    /recipes(.:format)          recipes#index
             POST   /recipes(.:format)          recipes#create
  new_recipe   GET    /recipes/new(.:format)      recipes#new
  edit_recipe  GET    /recipes/:id/edit(.:format) recipes#edit
  recipe      GET    /recipes/:id(.:format)      recipes#show
             PATCH  /recipes/:id(.:format)      recipes#update
             PUT    /recipes/:id(.:format)      recipes#update
             DELETE /recipes/:id(.:format)      recipes#destroy
  </code></pre>
  
  <p>Here is my index.html.erb file located in apps/views/recipes directory</p>
  
  <pre><code>&lt;h1&gt;Here is a list of recipes&lt;/h1&gt;
    &lt;table&gt;
      &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Recipe&lt;/th&gt;
      &lt;th&gt;Cook Time&lt;/th&gt;
      &lt;th&gt;Prep Time&lt;/th&gt;
      &lt;th&gt;Difficulty&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
      &lt;tbody&gt; 
    &lt;% @recipes.each do |recipe| %&gt;
      &lt;tr&gt;
        &lt;td&gt;&lt;%= recipe.recipe %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= recipe.cooktime %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= recipe.preptime %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;%= recipe.difficulty %&gt;&lt;/td&gt;
      &lt;/tr&gt;
    &lt;% end %&gt;
  &lt;/tbody&gt;
    &lt;/table&gt;
  </code></pre>
  
  <p>Here is my migrations file</p>
  
  <pre><code>class CreateRecipes &lt; ActiveRecord::Migration
    def change
      create_table :recipes do |t|
        t.string :recipe
        t.string :cooktime
        t.string :preptime
        t.integer :difficulty
  
        t.timestamps
      end
    end
  end
  </code></pre>
  
  <p>Here is my application.html.erb file used as a template for every webpage</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Recipes&lt;/title&gt;
        &lt;%= stylesheet_link_tag    "application", media: "all", "data-turbolinks-track" =&gt; true %&gt;
        &lt;%= javascript_include_tag "application", "data-turbolinks-track" =&gt; true %&gt;
      &lt;%= csrf_meta_tags %&gt;
    &lt;/head&gt;
    &lt;body&gt;
  
      &lt;%= yield %&gt;
  
      &lt;%= link_to "Home", recipes_path %&gt;
      &lt;%= link_to "Edit", edit_recipe_path(:id) %&gt;
      &lt;%= link_to "New", new_recupe_path %&gt;
      &lt;%= link_to "Delete" %&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I tried creating ActiveRecord objects through rails console and had them saved. So ActiveRecord objects do exist with IDs. I don't know where I went wrong here.</p>
  
  <p>If you need any more information, please let me know.</p>
  
  <p>I appreciate any help. Thank you for your time.</p>