Apipie / apipie-rails

Ruby on Rails API documentation tool
Apache License 2.0
2.47k stars 459 forks source link

Circular dependency detected while autoloading constant #418

Open twoneks opened 8 years ago

twoneks commented 8 years ago

Hi guys after almost 2 days I figured out that this error is caused by Apipie. Please look at this post http://stackoverflow.com/questions/34759750/circular-dependency-detected-while-autoloading-constant-controller I have

api! 'Create feedback'
param_group :feedback
def create
...
end

in my feedback_controller.rb.

The problem occur only when I call his son given_feedback_controller.rb or received_feedback_controller.rb and not when I call himself.

Doing so everythings work

#api! 'Create feedback'
#param_group :feedback
def create
...
end
Mexxerio commented 8 years ago

I just had the same problem when I started API versioning. It happened to me because I used several modules/namespaces for my versioning, and api! creates the url's automatically from routes.rb but couldn't handle my different modules.

I fixed it by just using e.g. api :GET, "/users/:id", "Show user profile" instead of api!

Hope that helps.

jeanlinux commented 7 years ago

I have the same issue, @Mexxerio tried your approach but still seems to be crashing with Circular dependency detected while autoloading constant Api::V1::DeviseTokenAuth::SessionsController

tennety commented 7 years ago

@jeanlinux I ran into the same issue, when trying @Mexxerio 's approach, I found I had to make the api! to api change in both the parent and subclass controllers. Hope that works for you. This is still less than ideal since hardcoding the route makes the API docs potentially inaccurate.