ruby-on-railsmailtolink-totargeting

mail_to address in seed database (Rails 5)


I have an item in a set of show profiles pages that gives an email from a seeded database:

  <h4><%= @admin.email %></h4>

Which needs to be converted into a mail_to tag, similar to this : <p><%= mail_to 'info@db.com', "info@db.com" %> What I came up with looks like this:

<% @admin.each do |agent| %>
  <h4<%= mail_to <%= agent.email %>, "<%= agent.email %>" %></h4>
<%end%>

But it's crashing, with the error syntax error, unexpected keyword_end, expecting ')' '.freeze; end ^

Any ideas?


Solution

  • Remove unnecessary <%%> symbols:

    <% @admin.each do |agent| %>
      <h4><%= mail_to agent.email, agent.email %></h4>
    <% end %>