【问题标题】:link on image and text in ruby on railsruby on rails 中的图像和文本链接
【发布时间】:2012-10-31 23:51:28
【问题描述】:

我想把它转换成 ruby​​ on rails 代码:

<a href="#"><span>Log out</span><%= image_tag("images/log-out.png") %></a>

尝试这个时:

<%= link_to image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>

我正在获取图片上的链接。但我还需要用文本添加跨度。我试过了,但它不起作用:-

 <%= link_to "<span>Log out</span>"+image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>

【问题讨论】:

标签: ruby-on-rails ruby-on-rails-3


【解决方案1】:

尝试:

 <%= link_to raw("<span>Log out</span>") + image_tag("images/log-out.png", :border => 0 ), destroy_user_session_path, :method => :delete %>

【讨论】:

  • 谢谢哥们,这对我有用。一段时间后我会接受这个作为答案,因为堆栈现在不允许我这样做。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-08
  • 1970-01-01
  • 1970-01-01
  • 2012-03-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多