Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to autoload constant API::KittensController [Rails]

I'm following a tutorial to learn the basics of API and I'm having troubles setting everything up. This is what I've done:

Rails.application.routes.draw do
  namespace :api, constraints: {format: :json} do
    resources :kittens
  end
end


#app/controllers/api/kittens_controller.rb
class API::KittenController < ApplicationController

  def index
  end

end

#config/initializers/inflections.rb
ActiveSupport::Inflector.inflections(:en) do |inflect|
  inflect.acronym 'API'
end

The error I get when visiting /api/kittens

Unable to autoload constant API::KittensController, expected /media/Volume.II/Dropbox/Web Development/odin-project/3. Ruby on Rails/odin-kittens/app/controllers/api/kittens_controller.rb to define it

Extracted source (around line #495):

        else
          require_or_load(expanded, qualified_name)
          raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false)
          return from_mod.const_get(const_name)
        end
      elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)

Any help would be really appreciated. Thanks.

like image 493
FranGoitia Avatar asked Apr 04 '15 15:04

FranGoitia


1 Answers

You have a typo in your class name: API::KittenController instead of API::KittensController.

like image 195
Tomáš Dundáček Avatar answered Nov 07 '22 20:11

Tomáš Dundáček