开发者

Rails 3 replace Link text with an Image

I'm having trouble replacing my link from text to an image in my Rails app.

In my .erb view, I have:

<%= link_to('Up!', vote_up_article_path(article), :method => :article) %>

I've got an arrow image in my public/images folder but I can't seem to be able to display it instead of the Up! text. Does anyone have any solutions that I c开发者_如何学Goan try? Any help is much appreciated. Thanks!


Something like this should work:

<%= link_to(image_tag('up.png'), ...) %>

(Obviously, change up.png to whatever the name of the image is.)


Simple:

<%= link_to( image_tag('path_to_image_inside_public_images.jpeg'), vote_up_article_path(article), :method => :post ) %>

But there is no "article" method on the HTTP protocol, I believe you probably meant either :post or :put.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜