开发者

Image links in embedded Ruby

开发者 https://www.devze.com 2023-02-13 17:37 出处:网络
I\'m a little confused. How would I go about producing this in embedded ruby? < a id=\"example\" href=\"image_tag thing.photo.url\" >< img alt=\"example3\" src=\"image_tag thing.photo.url(:

I'm a little confused.

How would I go about producing this in embedded ruby?

< a id="example" href="image_tag thing.photo.url" >< img alt="example3" src="image_tag thing.photo.url(:small开发者_如何转开发)" />< /a >


When you need to link a set of objects, rather than calling link_to name, path, options you can use a block, so you're sending in the method(s) you want it to execute. Use the "do" syntax:

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

精彩评论

暂无评论...
验证码 换一张
取 消