I have some namespaced controllers that live inapp/controllers/api/ and each are subclasses of an ApiController. This ApiController is a subclass of InheritedResources::Base.
When attempting to get the index on one of the Api::FooController subclasses, I get this error:
undefined method `all' for Api:Module
with this backtrace:
inherited_resources (1.3.0) lib/inherited_resources/base_helpers.rb:25:in `collection'
inherited_resources (1.3.0) lib/inherited_resources/actions.rb:7:in `index'
Changing the Api::FooController subclass to InheritedResources::Base allows it to work, but doesn't pull in my ApiController superclass that I need it to. Can inherited_resources be used if the controller is not a direct subclass of InheritedResources::Base?
I have found that making my ApiController superclass back into an ApplicationController subclass, then adding inherit_resources to the Api::FooControllers cases it to work. Is this the solution to the problem, or just a workaround?
I noticed that extending a controller within the same module seems to fix the problem as well. Creating an Api::BaseController with inherit_resources and extending it for controllers in that namespace/module DRYs it up a little.
There are a couple of solutions here (see above) so there is nothing more needed here. thx