ruby-on-railsactionmailermailerruby-on-rails-7

How to prevent Rails from rendering links when using partials in Mailer


I would like to reuse my partials in mailer layouts, but I want to avoid rendering the hyperlinks and instead print out just their name, like using link_to_if / link_to_unless methods.
Which condition could I check to prevent the rendering all the links inside mailer layouts?


Solution

  • Inside your email view, you can use something like this :

    <%= controller.class.name %>
    

    The printed controller name will be a mailer : "ApplicationMailer", ...

    You can then Regex or use a string helper ...