Question

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 methodconfig_accessor' for MetalController:Class (NoMethodError)

Rails 4.1.0, Ruby 2.1.0

Update:

If i include ActiveSupport::Configurable

throws the errors:

_implied_layout_name': undefined local variable or method controller_path' for MetalController:Class (NameError)

Was it helpful?

Solution

You need to inherit from ActionController::Metal:

class MetalController < ActionController::Metal
  ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left|
    include left
  end
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top