Reputation: 44370
I'm trying to create clean controller based on ActionController::Base
. That's what I try:
class MetalController
ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left|
include left
end
end
From Rails doc:
Shortcut helper that returns all the modules included in ActionController::Base except the ones passed as arguments:
This gives better control over what you want to exclude and makes it easier to create a bare controller class, instead of listing the modules required manually.
My another controller inherits from MetalController
:
class API::BaseController < MetalController
#.... my awesome api code
end
So this not work then i launch rails server
:
block in <module:AssetPaths>': undefined method
config_accessor' for MetalController:Class (NoMethodError)
Rails 4.1.0, Ruby 2.1.0
If i include ActiveSupport::Configurable
throws the errors:
_implied_layout_name': undefined local variable or method
controller_path' for MetalController:Class (NameError)
Upvotes: 2
Views: 706
Reputation: 44685
You need to inherit from ActionController::Metal
:
class MetalController < ActionController::Metal
ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left|
include left
end
end
Upvotes: 2