Class: SlashMigrate::AssetsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- SlashMigrate::AssetsController
- Defined in:
- app/controllers/slash_migrate/assets_controller.rb
Overview
Serves the engine’s vendored, precompiled JS/CSS straight from the gem, so the UI works identically no matter how the host app handles assets (or whether it has an asset pipeline at all). Files live under lib/ specifically so the host’s pipeline never scans or fingerprints them.
Constant Summary collapse
- ASSET_DIR =
SlashMigrate::Engine.root.join("lib/slash_migrate/assets")
- CONTENT_TYPES =
{".js" => "text/javascript", ".css" => "text/css"}.freeze
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/slash_migrate/assets_controller.rb', line 15 def show # File.basename strips any path components, so :name can only ever resolve # to a file directly inside ASSET_DIR — no directory traversal. path = ASSET_DIR.join(File.basename(params[:name].to_s)) raise ActionController::RoutingError, "Asset not found: #{params[:name]}" unless path.file? send_file path, type: CONTENT_TYPES.fetch(path.extname, "application/octet-stream"), disposition: "inline" end |