我正在尝试将标题放在html_options as described in the docs:
中link_to shop_path(@shop, html_options = {title: "Hola el mundo") do
content_tag( :span, "Hello", class: "some_class") + " " +
content_tag( :span, truncate(@shop.name, length: 37))
end
但它不起作用。我在哪里将title属性放在link_to块中?
答案 0 :(得分:3)
HTML属性可以作为link_to
的选项传递,而不是像_path
助手一样传递:
link_to shop_path(@shop), title: "Hola el mundo" do
content_tag( :span, "Hello", class: "some_class") + " " +
content_tag( :span, truncate(@shop.name, length: 37))
end