Skip to content

Notification URLs use hardcoded /error_dashboard path instead of respecting engine mount point #99

@paul

Description

@paul

Problem Statement

When the engine is mounted at a custom path, notification URLs (Slack, email, Jira) still link to /error_dashboard/errors/:id instead of the actual mount path. This results in broken links (404s) when users click through from notifications.

Reproduction

# config/routes.rb
mount RailsErrorDashboard::Engine, at: "/admin/errors"

# config/initializers/rails_error_dashboard.rb
config.dashboard_base_url = "https://myapp.com"

A Slack notification for error ID 4 links to:

https://myapp.com/error_dashboard/errors/4    # 404

Expected:

https://myapp.com/admin/errors/errors/4

Root cause

The path /error_dashboard/errors/ is hardcoded in three locations:

  1. lib/rails_error_dashboard/services/notification_helpers.rb:17
  2. lib/rails_error_dashboard/plugins/jira_integration_plugin.rb:117
  3. app/mailers/rails_error_dashboard/error_notification_mailer.rb:19

These all construct URLs like:

"#{base_url}/error_dashboard/errors/#{error_log.id}"

The engine mount point set in the host app's routes.rb is not consulted.

Proposed Solution

Include the host app's route helpers in NotificationHelpers and define default_url_options so the _url helpers can generate full URLs:

module NotificationHelpers
  include Rails.application.routes.url_helpers

  def default_url_options
    { host: RailsErrorDashboard.configuration.dashboard_base_url }
  end

  module_function

  def dashboard_url(error_log)
    rails_error_dashboard.error_url(error_log)
  end
end

rails_error_dashboard is the routing proxy for the engine as mounted in the host app, so error_url automatically includes the mount point. The default_url_options pulls the host from the existing dashboard_base_url configuration, so no new config is needed.

This change would need to be applied in all three locations that currently hardcode the path:

  1. lib/rails_error_dashboard/services/notification_helpers.rb:17
  2. lib/rails_error_dashboard/plugins/jira_integration_plugin.rb:117
  3. app/mailers/rails_error_dashboard/error_notification_mailer.rb:19

Alternatives Considered

No response

Use Case

I'd like my slack alerts to be clickable when the engine is mounted at a different path than the default 😀

Feature Type

Enhancement to existing feature

Priority/Impact

Medium - Would be nice to have

Examples/References

No response

Implementation Ideas

No response

Contribution

  • I'd be willing to submit a PR for this feature
  • I'd be willing to help test this feature

Pre-submission Checklist

  • I have searched existing issues and feature requests to ensure this is not a duplicate
  • I have read the documentation to ensure this feature doesn't already exist
  • This feature aligns with the project's goals and scope

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions