ActionController::API vs ActionController::Base

77 Views Asked by At

I want to know what all functionalities are restricted in API and will there be any difference in speed if we use Base in place of API.

I searched many places to find the difference between those two modules, all I was able to know it API is light weight version of Base.

1

There are 1 best solutions below

2
spickermann On BEST ANSWER

The best source to understand the differences between both is certainly the list of modules they include in the source code.

Which ActionController::Base includes these modules (comments removed and sorted alphabetically):

MODULES = [
  AbstractController::AssetPaths,
  AbstractController::Callbacks,
  AbstractController::Rendering,
  AbstractController::Translation,
  ActionView::Layouts,
  Caching,
  ConditionalGet,
  ContentSecurityPolicy,
  Cookies,
  DataStreaming,
  DefaultHeaders,
  EtagWithFlash,
  EtagWithTemplateDigest,
  Flash,
  FormBuilder,
  Helpers,
  HttpAuthentication::Basic::ControllerMethods,
  HttpAuthentication::Digest::ControllerMethods,
  HttpAuthentication::Token::ControllerMethods,
  ImplicitRender,
  Instrumentation,
  Logging,
  MimeResponds,
  ParameterEncoding,
  ParamsWrapper,
  PermissionsPolicy,
  Redirecting,
  Renderers::All,
  Rendering,
  RequestForgeryProtection,
  Rescue,
  Streaming,
  StrongParameters,
  UrlFor,
]

While ActionController::API only includes these (again, comments removed and sorted alphabetically):

MODULES = [
  AbstractController::Callbacks,
  AbstractController::Rendering,
  ApiRendering,
  BasicImplicitRender,
  ConditionalGet,
  DataStreaming,
  DefaultHeaders,
  Instrumentation,
  Logging,
  ParamsWrapper,
  Redirecting,
  Renderers::All,
  Rescue,
  StrongParameters,
  UrlFor,
]