Morgan
Morgan

Reputation: 1449

Rails + rails-api: Circular Dependency with Helper

I have a module ApiHelper in the helpers api_helper folder that's causing a bit of mayhem. In controllers/api/v1 I have two controllers, both of which have

include ApiHelper

The exact error is:

/Users/WEF6/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:461:in `load_missing_constant': Circular dependency detected while autoloading constant APIHelper (RuntimeError)

I'm thinking this issue is happening because I have an api_controller that is set up like this using rails-api:

class ApiController < ActionController::API

and my normal application controller set up like this

class ApplicationController < ActionController::Base

The api controllers inherit from the ApiController, while my normal App controllers inherit from the ApplicationController.

Or it might be something much more simple; thoughts?

Upvotes: 1

Views: 266

Answers (1)

Gob
Gob

Reputation: 315

I know this is old, but I ran into a similar problem recently. In my case the problem was the addition of an inflection acronym for 'API' to config/initializers/inflections.rb.

All I had to do to solve this was to rename ApiHelper to APIHelper and the problem was solved.

Upvotes: 0

Related Questions