Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4636

NameError: uninitialized constant Api::V1::Item::ItemsController::Item

$
0
0

I have controller:

class Api::V1::Item::ItemsController < ApplicationController  def index     @items = Item.all      render json: @items  endend

and routes for this controller:

 namespace :api do  namespace :v1 do   namespace :item do     resources :items   end  end end 

If I check this in postman, I obtain an error:

{"status": 500,"error": "Internal Server Error","exception": "#<NameError: uninitialized constant Api::V1::Item::ItemsController::Item>", }

But if I modify controller`s method index like:

  def index     render json: { check: 'Nice' }  end

everything will be fine. Please explain to me what the problem is.


Viewing all articles
Browse latest Browse all 4636

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>