use*_*705 20 image link-to ruby-on-rails-3
<%= link_to ((image_tag 'image.png'),
url_for({:controller => 'controller_name', :action => 'action_name'}),
:class => 'quick',
:remote => true) %>
Run Code Online (Sandbox Code Playgroud)
这部分代码将生成image.png作为链接.我需要这个图像附加一些文本(图像+文本),我尝试了类似的东西:
<%= link_to ((image_tag 'image.png', 'text'),
url_for({:controller => 'controller_name', :action => 'action_name'}),
:class => 'quick',
:remote => true) %>
Run Code Online (Sandbox Code Playgroud)
和类似的方式,但这些尝试中的每一个都以一个关于错误语法的错误消息结束......任何人都可以帮助我,请问我应该如何设置它?
提前致谢.
Muh*_*lid 44
试试这个.
<%= link_to image_tag('/images/image.png') + "some extra text", url_for({:controller => 'controller_name', :action => 'action_name'}), :class => 'quick', :remote => true %>
Run Code Online (Sandbox Code Playgroud)
And*_*rie 10
一个稍微性感的解决方案?
<%= link_to image_tag("image.png", :alt => "Image Description", :class => "css"), root_path %>
Run Code Online (Sandbox Code Playgroud)