[英]Link_to a page - Ruby on Rails
I have the following code: 我有以下代码:
<% slika = Refinery::Page.find('sladoledi') %>
<%= link_to (image_tag slika.key_image.url, slika) %>
The problem is that it's not linking to slika
. 问题是它没有链接到
slika
。 Any suggestions? 有什么建议么?
Try this format 试试这种格式
<%= link_to(slika) do %>
<%= image_tag(slika.key_image.url)%>
<% end %>
also have a look at documentation there are nice examples how to use link_to() helper 另外看看文档有很好的例子如何使用link_to()帮助器
http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to
First start nesting code you write here. 首先开始嵌套你在这里写的代码。 People have problem reading code like this :(
人们有这样的问题阅读代码:(
If you want add code click code button on editor. 如果要添加代码,请单击编辑器上的代码按钮。
I suppose the problem is you don't end image_tag. 我想问题是你没有结束image_tag。
Correct form is: 正确的形式是:
link_to(image_tag(slika.key_image.url),slika)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.