开发者

Why does rails 3 show "(/)" when I use the link_to img_tag helpers?

开发者 https://www.devze.com 2023-02-06 17:50 出处:网络
here\'s the code: <%= link_to tag(\"img\"开发者_Python百科, { :src => \"/images/logo.png\", :alt => \"logo\"}, false), {:controller => \'frontpage\', :action => \'index\'}, :class =>

here's the code:

    <%= link_to tag("img"开发者_Python百科, { :src => "/images/logo.png", :alt => "logo"}, false), {:controller => 'frontpage', :action => 'index'}, :class => "logo" %>   

the output:

Why does rails 3 show "(/)" when I use the link_to img_tag helpers?

'(/)'

the '(/)' --minus the quotes, come at the end of the image


Are you sure you don't have that floating in your HTML somewhere?

Also, you're doing a lot more work than necessary:

<%= link_to image_tag('logo.png'), frontpages_path, :class => 'logo' %>

That'll automatically assign "Logo" as the alt text, and assuming you're using RESTful routes, that frontpages_path helper will already exist.

0

精彩评论

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