Cannot automatically load API constant :: KittensController [Rails]

I am following the tutorial on learning the basics of the API, and I'm having trouble configuring it. This is what I did:

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.

+6
source share
1 answer

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

+3
source

Source: https://habr.com/ru/post/984683/


All Articles