diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-08-26 03:07:30 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2013-08-26 03:07:30 -0700 |
commit | c19958015fac7b50f8dedbdf17991c00d6b8bbd4 (patch) | |
tree | 42431a33fd65c954b1242b8ff6116163c9969924 /actionpack/lib/action_controller/base.rb | |
parent | 27dc4fa28ee098d70a11829ad5fa4af0c54e880b (diff) | |
parent | 0d43df7ebf7587f032e3b16c153bf35746878c46 (diff) | |
download | rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.tar.gz rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.tar.bz2 rails-c19958015fac7b50f8dedbdf17991c00d6b8bbd4.zip |
Merge pull request #11396 from strzalek/extract_renderers
Remove dependency on Action View from Action Pack
This set of changes removes the need of using Action View with Action Pack.
Now you may use controllers without Action View, by rendering `:text` response
or alternatively you can plug in your own rendering logic. This is especially
handy when you're just dealing with APIs and don't need to include entire
Action View just to render simple JSON responses.
Diffstat (limited to 'actionpack/lib/action_controller/base.rb')
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 67d261db77..9941c06201 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -2,6 +2,21 @@ require "action_controller/log_subscriber" require "action_controller/metal/params_wrapper" module ActionController + # The <tt>metal</tt> anonymous class was introduced to solve issue with including modules in <tt>ActionController::Base</tt>. + # Modules needes to be included in particluar order. First wee need to have <tt>AbstractController::Rendering</tt> included, + # next we should include actuall implementation which would be for example <tt>ActionView::Rendering</tt> and after that + # <tt>ActionController::Rendering</tt>. This order must be preserved and as we want to have middle module included dynamicaly + # <tt>metal</tt> class was introduced. It has <tt>AbstractController::Rendering</tt> included and is parent class of + # <tt>ActionController::Base</tt> which includes <tt>ActionController::Rendering</tt>. If we include <tt>ActionView::Rendering</tt> + # beetween them to perserve the required order, we can simply do this by: + # + # ActionController::Base.superclass.send(:include, ActionView::Rendering) + # + metal = Class.new(Metal) do + include AbstractController::Rendering + include ActionController::BasicRendering + end + # Action Controllers are the core of a web request in \Rails. They are made up of one or more actions that are executed # on request and then either it renders a template or redirects to another action. An action is defined as a public method # on the controller, which will automatically be made accessible to the web-server through \Rails Routes. @@ -160,7 +175,7 @@ module ActionController # render action: "overthere" # won't be called if monkeys is nil # end # - class Base < Metal + class Base < metal abstract! # We document the request and response methods here because albeit they are @@ -200,7 +215,6 @@ module ActionController end MODULES = [ - AbstractController::Layouts, AbstractController::Translation, AbstractController::AssetPaths, |