Issue
I run the Rails command bin/rails generate sentry to set up Sentry in my Rails app, and I see an error stating that the file application.html.erb does not exist. I do not use that file, for example because I have an API-only Rails app.
Applies To
Ruby SDK users
Resolution
When you run bin/rails generate sentry, the generator does two things: it creates the Sentry initializer at config/initializers/sentry.rb, and it injects one line into the <head> of your application.html.erb layout. The injected line is:
<%= Sentry.get_trace_propagation_meta.html_safe %>
This line adds the sentry-trace and baggage meta tags so the browser SDK can continue your server-side trace for Distributed Tracing. The generator fails when your app has no application.html.erb layout, for example in an API-only Rails app.
To resolve the error:
Skip the meta tag injection by running the generator with the
--inject-metaflag. The initializer is still generated:bin/rails generate sentry --inject-meta false
If your app renders HTML with a different templating engine, add the meta tag to the
<head>of your layout manually and convert it to your engine's syntax.
Note: Inject these meta tags only on dynamically rendered pages. If you cache the rendered tags, every user shares the same trace context, which breaks Distributed Tracing.
For details, see Inject Tracing Information Into Rendered HTML.
