Reputation: 7065
My app/
folder looks like this
.
├── controllers
| └── api
| └── v1
| ├── card_controller.rb
| └── user_controller.rb
| └── website
| └── account_controller.rb
...
I'd like the controllers in the website
folder to inherit from a WebsiteController
and the controllers in the api
folder to inherit from an ApiController
. How can this be achieved? Specifically, what files need to be created, and what class definitions must be used?
Upvotes: 1
Views: 628
Reputation: 19524
I recommend creating inheritable classes in controllers/website/website_controller.rb
and controllers/api/v1/api_controller.rb
.
You may use the following to easily inherit from these new controllers. This is similar to how the default generated Rails app has every controller inherit from ApplicationController
.
class WebsiteController < ApplicationController
end
class AccountController < WebsiteController
end
Upvotes: 1