I have referred this link
to create my own api but facing an routing error since this is the first time am using namespace.
This is the controller I have
class API::IndexController < ApplicationController
def index
@clients = Client.all
respond_to do |format|
format.json
end
end
end
my route has
namespace :api do
resources :index
end
Here is my inflection.rb
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.acronym 'API'
end
Once i finish it I tried localhost:3000/api/index.json but throwing error as
Routing Error
uninitialized constant API
Can anyone help.
Even if this question is pretty old...
I had the same problem and my solution was to rename the api-folders (in app/controllers and app/views) from "API" (full caps) to "api" (all lower case)
Hope this helps