diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2018-04-13 16:23:04 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2018-04-13 16:23:04 -0700 |
commit | f1d74871e7f00e8bbde3501a759487ac8cc4c3fc (patch) | |
tree | 2f1fa680bd1e6a356256fdc59cab5a6af8d74da7 /lib/action_text/engine.rb | |
parent | 3bc244abc1800c7617cbfbbe1dd2597053a638c9 (diff) | |
download | rails-f1d74871e7f00e8bbde3501a759487ac8cc4c3fc.tar.gz rails-f1d74871e7f00e8bbde3501a759487ac8cc4c3fc.tar.bz2 rails-f1d74871e7f00e8bbde3501a759487ac8cc4c3fc.zip |
Rename from Active Text to Action Text
This is more like Action View than Active Model.
Diffstat (limited to 'lib/action_text/engine.rb')
-rw-r--r-- | lib/action_text/engine.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/action_text/engine.rb b/lib/action_text/engine.rb new file mode 100644 index 0000000000..71db6d6a26 --- /dev/null +++ b/lib/action_text/engine.rb @@ -0,0 +1,45 @@ +require "rails/engine" + +module ActionText + class Engine < Rails::Engine + isolate_namespace ActionText + config.eager_load_namespaces << ActionText + + initializer "action_text.attribute" do + ActiveSupport.on_load(:active_record) do + include ActionText::Attribute + end + end + + initializer "action_text.active_storage_extension" do + require "active_storage/blob" + + class ActiveStorage::Blob + include ActionText::Attachable + + def previewable_attachable? + representable? + end + end + end + + initializer "action_text.helper" do + ActiveSupport.on_load(:action_controller_base) do + helper ActionText::TagHelper + end + end + + initializer "action_text.config" do + config.after_initialize do |app| + ActionText.renderer ||= ApplicationController.renderer + + # FIXME: ApplicationController should have a per-request specific renderer + # that's been set with the request.env env, and ActionText should just piggyback off + # that by default rather than doing this work directly. + ApplicationController.before_action do + ActionText.renderer = ActionText.renderer.new(request.env) + end + end + end + end +end |