RailsCasts Pro episodes are now free!

Learn more or hide this

Mike Lawlor's Profile

GitHub User: disbelief

Comments by Mike Lawlor

Avatar

Solved

The problem was on my end. One of the gems my app depends on was overriding the String#constantize method, and it was breaking the resolution of the routing namespace. Removing that gem fixes my problem.

Sorry for the bother.

Avatar

For some reason I can't get my app to work based on the sample code for this screencast. After setting up the routes, api_constraints, and the api/v1/ controller directory structure, API requests fail with the exception:

console
ActionController::RoutingError (wrong constant name v1):
  app/controllers/api/v1/base_controller.rb:3:in `<module:V1>'
  app/controllers/api/v1/base_controller.rb:2:in `<module:Api>'
  app/controllers/api/v1/base_controller.rb:1:in `<top (required)>'
  app/controllers/api/v1/groups_controller.rb:1:in `<top (required)>'

My controller at app/controllers/api/v1/groups_controller.rb looks like this:

ruby
module Api
  module V1
    class GroupsController < ApplicationController
      respond_to :json

      # ... snip ....

    end
  end
end
end

My Routes look like this:

ruby
  # ... snip ... 
  namespace :api, defaults: {format: 'json'} do
    scope module: :v1, constraints: ApiConstraints.new(version: 1, default: true) do
      resources :groups
    end
  end
  # ... snip ... 

Anyone else have this problem? Have I missed something?