问题
I have the following html
<a href="#" data-hover="Seraglio"><span>Seraglio</span></a>
How do I convert it to RoR ?
回答1:
Syntax:
link_to(body, url, html_options = {})
So for your example, in .erb format:
<%= link_to("#", {"data-hover" => "Seraglio"}) do %>
<span>Seraglio</span>
<% end %>
Docs: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to
回答2:
You may do it this way:-
link_to(body, url, :data =>{:hover => your_data_hover_value})
来源:https://stackoverflow.com/questions/19779979/what-is-the-equivalent-of-data-hover-in-a-ruby-on-rails-link-to-block