title: Rails - Dynamically switch confirm messages in a link_to
body: <p>I am facing this ugly duplication in order to display different confirmation message in my view.</p>
  
  <pre><code>&lt;% if current_user.password.nil? and current_user.services.count == 1 %&gt;
    &lt;%= link_to "Disconnect #{service.provider.capitalize}", service, :confirm =&gt; 'Remove this service will delete your account, are you sure?', :method =&gt; :delete %&gt;
  &lt;% else %&gt;
    &lt;%= link_to "Disconnect #{service.provider.capitalize}", service, :confirm =&gt; 'Are you sure you want to remove this authentication option?', :method =&gt; :delete %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>I would be pleased to know if there is a way to avoid this?</p>
  
  <p>Thank you!</p>
  
  <p>EDIT:</p>
  
  <pre><code>ActionView::Template::Error (/Users/benoit/rails_projects/website/app/views/services/index.html.erb:15: syntax error, unexpected ',', expecting ')'
  ...e this authentication option?', :method =&gt; :delete, :class =...
  ...                               ^):
      12:         &lt;% for service in @services %&gt;
      13:           &lt;div class="service"&gt;
      14:             &lt;%= image_tag "logo_#{service.provider}.png", :class =&gt; "left" %&gt;
      15: &lt;%= link_to "Disconnect #{service.provider.capitalize}", service, :confirm =&gt; current_user.password.nil? and current_user.services.count == 1 ? 'Remove this service will delete your account, are you sure?' : 'Are you sure you want to remove this authentication option?', :method =&gt; :delete, :class =&gt; "remove" %&gt;
      16: 
      17:             &lt;div class="clear"&gt;&lt;/div&gt;
      18:           &lt;/div&gt;
  </code></pre>