简体   繁体   中英

rails link_to video not working

I had this line of code in my html.erb file in the static folder:

<a href="<%= video['link'] %>" role="tab" data-toggle="tab"><%= video['caption'] %></a>

I changed it to:

<%= link_to video['link'], video['caption'], role: 'tab', data: { toggle: 'tab' } %>

Now my video is not loading and the caption is showing up as the URL of the video. Can anybody tell me what's going on here.

Thanks.

I figured it out:

You change it to:

<%= link_to video['caption'], video['link'], role: 'tab', data: { toggle: 'tab' } %>

尝试这个....

<%= link_to video['caption'], video['link'], role: 'tab', data: { toggle: 'tab' } %>

link_to helper take display text as first parameter and url as second parameter. So

<%= link_to video['caption'], video['link'], role: 'tab', data: { toggle: 'tab' } %>

Or if you need formatted html instead of plain text, try something like

<%= link_to video['link'], role: 'tab', data: { toggle: 'tab' } do %>
   <b><%= video[:caption] %></b>
<% end %>

For more details, please visit apidock

http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM