ruby-on-railsrubycontrollercomfortable-mexican-sofa

Is reasonable to exclude ActionController::Base if the gem in application dependant on Rails


I have a slight dilemma, where some people suggest to exclude ActionController::Base from a Controller tree inheritance and use ActionController::Metal instead to speed up the performance of requests, however the main application is dependant on Comfortable Mexican Sofa CMS, which is dependent on Rails stack.

Hence the question would be what:


Solution

  • ActionController::Metal is actually a sub version on ActionController::Base. It doesn't include utilities for rendering views, partials, or other responses, thus improving the performance. People have been reporting 25x speed increase over a regular Rails action as per RubyOnRails blogs. But ActionContoller:Metal is mostly used for building APIs, where you can manually specify only the utilities that are required in the application.

    For example:

    class ApiController < ActionController::Metal
      include AbstractController::Rendering
      include ActionView::Layouts
    

    You can measure the performance of controller actions by using a gem called rack-mini-profiler or you can use rails benchmark testing for the same.