Class: RailsPulse::ApplicationHelper::RailsPulseHelper
- Inherits:
-
Object
- Object
- RailsPulse::ApplicationHelper::RailsPulseHelper
- Defined in:
- app/helpers/rails_pulse/application_helper.rb
Overview
Helper class to provide both routes and asset methods
Instance Method Summary collapse
-
#asset_path(asset_name) ⇒ Object
Generate asset paths using Rails asset pipeline This allows assets to work with CDN, digests, and precompiled manifests.
-
#initialize(view_context) ⇒ RailsPulseHelper
constructor
A new instance of RailsPulseHelper.
-
#method_missing(method, *args, &block) ⇒ Object
Delegate route methods to engine routes.
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
Constructor Details
#initialize(view_context) ⇒ RailsPulseHelper
Returns a new instance of RailsPulseHelper.
80 81 82 |
# File 'app/helpers/rails_pulse/application_helper.rb', line 80 def initialize(view_context) @view_context = view_context end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Delegate route methods to engine routes
85 86 87 88 89 90 91 |
# File 'app/helpers/rails_pulse/application_helper.rb', line 85 def method_missing(method, *args, &block) if RailsPulse::Engine.routes.url_helpers.respond_to?(method) RailsPulse::Engine.routes.url_helpers.send(method, *args, &block) else super end end |
Instance Method Details
#asset_path(asset_name) ⇒ Object
Generate asset paths using Rails asset pipeline This allows assets to work with CDN, digests, and precompiled manifests
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/helpers/rails_pulse/application_helper.rb', line 99 def asset_path(asset_name) # Only use asset pipeline if we have Sprockets/Propshaft configured # Otherwise fall back to middleware serving if defined?(::Sprockets) || defined?(::Propshaft) # Use the main application's asset_path helper to ensure we get # the correct digested paths from the precompiled manifest begin ActionController::Base.helpers.asset_path(asset_name) rescue => e # Fallback to direct path if asset pipeline is not available Rails.logger.warn "[Rails Pulse] Asset pipeline error for #{asset_name}: #{e.}" "/rails-pulse-assets/#{asset_name}" end else # No asset pipeline - use middleware serving "/rails-pulse-assets/#{asset_name}" end end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
93 94 95 |
# File 'app/helpers/rails_pulse/application_helper.rb', line 93 def respond_to_missing?(method, include_private = false) RailsPulse::Engine.routes.url_helpers.respond_to?(method, include_private) || super end |