1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/action_text/engine.rb

46 lines
1.2 KiB
Ruby
Raw Normal View History

2018-02-07 13:43:36 -05:00
require "rails/engine"
module ActionText
2018-02-07 13:43:36 -05:00
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
2018-02-12 10:16:49 -05:00
initializer "action_text.active_storage_extension" do
2018-02-12 18:21:49 -05:00
require "active_storage/blob"
class ActiveStorage::Blob
include ActionText::Attachable
2018-02-12 18:21:49 -05:00
def previewable_attachable?
representable?
end
end
end
initializer "action_text.helper" do
2018-02-12 10:16:49 -05:00
ActiveSupport.on_load(:action_controller_base) do
helper ActionText::TagHelper
2018-02-12 10:16:49 -05:00
end
end
2018-02-14 09:43:49 -05:00
initializer "action_text.config" do
2018-02-14 09:43:49 -05:00
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
2018-02-14 09:43:49 -05:00
end
end
2018-02-07 13:43:36 -05:00
end
end