Trj
Trj

Reputation: 677

In middleman, create a dynamic URL in link_to?

I'm new to middleman and ruby so the syntax is very unfamiliar. I have setup a simple list page and a dynamic article page. This all works fine, but how do i generate the dynamic URL in link_to?

My list page is at localhost/list/ And my dynamic article page should be localhost/list/1/ where the number is dynamic.

<% data.list.each do |b| %>
    <%= link_to 'Read more', '/list/b.id.html' %>
<% end %>

How can I generate the dynamic URL?

Upvotes: 0

Views: 454

Answers (1)

Trj
Trj

Reputation: 677

<%= link_to 'Read more', '/list/' + b.id.to_s + '.html' %>

Upvotes: 1

Related Questions