Timsen
Timsen

Reputation: 4126

uninitialized constant Api in Rails app

Im trying to folow some base pointers of this guide : http://rockyj.in/2013/10/24/angular_rails.html

ive created a controller named PeopleController :

module Api
  module V1
    class PeopleController < ApplicationController

      def greet
        render :json => {message: "Hello World!"}.as_json
      end

    end
  end
end

in this controller there si a simple greet method which return Hello world as json when its called.

My route:

Rails.application.routes.draw do
  namespace :api, defaults: {format: 'json'} do
    namespace :v1 do
      get "/greet" => "people#greet", :as => 'greet'
    end
  end
end

so if i call this url i should get json response : /api/v1/greet.json but instead i am getting uninitialized constant Api, and after about 4 hours of struggle i really cant find out what i did wrong.

What is it that i've done wrong?

Upvotes: 0

Views: 902

Answers (1)

avl
avl

Reputation: 662

In your config/environments/development.rb

config.eager_load = true

Upvotes: 1

Related Questions