I'm really sorry to ask this when there are a lot of similar posts but none seams to work for me.
/app/controllers/api/v1/musics_controller.rb:
class Api::V1::MusicsController < ApplicationController::API
def index
music = Music.order('created_at DESC');
render json: {status: 'SUCCESS', message:'Loaded articles', data:music},status: :ok
end
end
config/routes.rb:
Rails.application.routes.draw do
namespace 'api' do
namespace 'v1' do
resources :music
end
end
end
Error:
activesupport (5.1.2) lib/active_support/inflector/methods.rb:271:in
const_get' activesupport (5.1.2) lib/active_support/inflector/methods.rb:271:in
block in constantize' activesupport (5.1.2) lib/active_support/inflector/methods.rb:267:ineach' activesupport (5.1.2) lib/active_support/inflector/methods.rb:267:in
inject' activesupport (5.1.2) lib/active_support/inflector/methods.rb:267:inconstantize' actionpack (5.1.2) lib/action_dispatch/http/request.rb:82:in
controller_class' actionpack (5.1.2) lib/action_dispatch/routing/route_set.rb:43:incontroller' actionpack (5.1.2) lib/action_dispatch/routing/route_set.rb:29:in
serve' actionpack (5.1.2) lib/action_dispatch/journey/router.rb:46:inblock in serve' actionpack (5.1.2) lib/action_dispatch/journey/router.rb:33:in
each' actionpack (5.1.2) lib/action_dispatch/journey/router.rb:33:inserve' actionpack (5.1.2) lib/action_dispatch/routing/route_set.rb:832:in
call' rack (2.0.3) lib/rack/etag.rb:25:incall' rack (2.0.3) lib/rack/conditional_get.rb:25:in
call' rack (2.0.3) lib/rack/head.rb:12:incall' rack (2.0.3) lib/rack/session/abstract/id.rb:232:in
context' rack (2.0.3) lib/rack/session/abstract/id.rb:226:incall' actionpack (5.1.2) lib/action_dispatch/middleware/cookies.rb:613:in
call' activerecord (5.1.2) lib/active_record/migration.rb:556:incall' actionpack (5.1.2) lib/action_dispatch/middleware/callbacks.rb:26:in
block in call' activesupport (5.1.2) lib/active_support/callbacks.rb:97:inrun_callbacks' actionpack (5.1.2) lib/action_dispatch/middleware/callbacks.rb:24:in
call' actionpack (5.1.2) lib/action_dispatch/middleware/executor.rb:12:incall' actionpack (5.1.2) lib/action_dispatch/middleware/debug_exceptions.rb:59:in
call' actionpack (5.1.2) lib/action_dispatch/middleware/show_exceptions.rb:31:incall' railties (5.1.2) lib/rails/rack/logger.rb:36:in
call_app' railties (5.1.2) lib/rails/rack/logger.rb:24:inblock in call' activesupport (5.1.2) lib/active_support/tagged_logging.rb:69:in
block in tagged' activesupport (5.1.2) lib/active_support/tagged_logging.rb:26:intagged' activesupport (5.1.2) lib/active_support/tagged_logging.rb:69:in
tagged' railties (5.1.2) lib/rails/rack/logger.rb:24:incall' actionpack (5.1.2) lib/action_dispatch/middleware/remote_ip.rb:79:in
call' actionpack (5.1.2) lib/action_dispatch/middleware/request_id.rb:25:incall' rack (2.0.3) lib/rack/method_override.rb:22:in
call' rack (2.0.3) lib/rack/runtime.rb:22:incall' activesupport (5.1.2) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in
call' actionpack (5.1.2) lib/action_dispatch/middleware/executor.rb:12:incall' actionpack (5.1.2) lib/action_dispatch/middleware/static.rb:125:in
call' rack (2.0.3) lib/rack/sendfile.rb:111:incall' railties (5.1.2) lib/rails/engine.rb:522:in
call' puma (3.9.1) lib/puma/configuration.rb:224:incall' puma (3.9.1) lib/puma/server.rb:602:in
handle_request' puma (3.9.1) lib/puma/server.rb:435:inprocess_client' puma (3.9.1) lib/puma/server.rb:299:in
block in run' puma (3.9.1) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
Music
orMusics
? – Sebastian Palmaresources :music
forMusicController
;resources :musics
forMusicsController
– Andrei