Module: Blazer::Ai::UrlHelper
- Defined in:
- lib/blazer/ai/url_helper.rb
Overview
Provides URL helpers for Blazer AI routes. Computes path fresh each time to handle development reloads and multi-tenant scenarios where mount points may vary.
Class Method Summary collapse
-
.blazer_ai_generate_sql_path ⇒ Object
Returns the path to the generate_sql endpoint.
Class Method Details
.blazer_ai_generate_sql_path ⇒ Object
Returns the path to the generate_sql endpoint. Automatically detects Blazer's mount point.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/blazer/ai/url_helper.rb', line 7 def self.blazer_ai_generate_sql_path path = "/ai/generate_sql" if defined?(Rails.application) # Find the route that mounts Blazer::Engine # The route name could be 'blazer', 'admin_blazer', etc. main_route = Rails.application.routes.routes.find do |r| r.app.respond_to?(:app) && r.app.app == Blazer::Engine end if main_route blazer_mount = main_route.path.spec.to_s.gsub("(.:format)", "") path = blazer_mount + path end end path end |