Senator Senator - 1 year ago 60
Ruby Question

How to merge a variable title and link_to button in one button?

I'm new to rails/html and I'm struggling to combine a title which varies from 'outing' to 'outing' and the link_to function would take the user to the 'more details' information on that 'outing.

Both buttons are working as coded independently but would look much better in the carousel if combined but I can't figure how I would add the 'link_to' into the href OR how to add the <%= outing.date_title %> into the 'link_to' button. Thanks !

<div class="carousel-caption caption-shadow-large">
<p><a class="btn btn-default" href="#" role="button"><%= outing.date_title %></a></p>
<div class="btn-group">
<%= link_to 'more details', outing,
:class => "btn btn-default align-center" %>

Answer Source

you can customize what to display in the link to by doing this

   <%= link_to(outing) do %>
      <strong><%= outing.date_title  %></strong> -- <span>More details</span>
   <% end %>


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download