title: In rails error is as NameError in ProductsController#index
body: <p>I have written a controller and model to get data from db. But it shows the error when we run rails is:NameError in ProductsController#index  in the url.. i give my url as localhost:3000/products. then it is giving error as:</p>
  
  <pre><code> NameError in ProductsController#index
  
      uninitialized constant ProductsController::Product.
  
  
      my controller is:
      products_controller.rb
      class ProductsController &lt; ApplicationController
        # GET /products
        # GET /products.json
  
        def index
          @products = Product.all
          respond_to do |format|
            format.html # index.html.erb
            format.json { render json: @products }
          end
        end
  
        #render :text =&gt; params and return false
        # GET /products/PR1
        # GET /products/PR1.json
        def show
          @product = Product.find(params[:prod_id])
  
          respond_to do |format|
            format.html # show.html.erb
            format.json { render json: @product }
          end
        end
  
      end
  
      model as product.rb
      class Product &lt; ActiveRecord::Base
        attr_accessible :model_name, :brand_name, :price, :discount, :qty_available
      end
  </code></pre>
  
  <p>i declared in routes.rb as:
  resources :products</p>
  
  <p>and i designed index.html.erb and show.html.erb</p>
  
  <p>I dont know where the error is really...</p>