2011-02-28 86 views
1

我有点困惑。嵌入式Ruby中的图像链接

我该如何去制作嵌入式红宝石?

< a id="example" href="image_tag thing.photo.url" >< img alt="example3" src="image_tag thing.photo.url(:small)" /></a>

+0

hmm ...等一下......嗯......什么? – 2011-02-28 14:00:26

+0

固定那个对不起.. – elkalto23 2011-02-28 14:08:16

+0

你想用Ruby或Rails做这个吗? – Tarscher 2011-02-28 14:09:22

回答

3

当你需要连接一组对象,而不是调用link_to name, path, options你可以使用一个块,所以你在你想让它执行的方法(一个或多个)发送。使用“do”语法:

<%= link_to thing.photo.url, :id=>'example' do 
     image_tag(thing.photo.url(:small), :alt=>"example3") 
    end 
%> 
+0

谢谢!你得到了我想要的 – elkalto23 2011-02-28 14:28:37

+0

+1我不知道这个功能。谢谢杰西。 – McStretch 2011-02-28 14:29:55