Rails 在数据内容助手上添加动态属性 link
Rails add dynamic attribute on data content helper link
我需要在动态 link 上获得 ajax 工具提示,因此逻辑似乎将其串联起来。但是,还是不行,所以,有人知道这样做的方法吗?
谢谢
<%= link_to "Profile", edit_user_path(current_user), :class =>"ttooltip", :data => {:url => "/users/#{@current_user}/links"} %>
您正在插入当前用户对象的字符串,这将在用户对象上调用 .to_s,这可能不是您想要的。
如果链接嵌套在每个用户下,您通常遵循 'users/:id/links' 因此您需要插入 id 而不是用户对象,如下所示:
<%= link_to "Profile", edit_user_path(current_user), :class =>"ttooltip", :data => {:url => "/users/#{current_user.id}/links"} %>
(其中 current_user 是 returns current_user 对象的辅助方法。)
我需要在动态 link 上获得 ajax 工具提示,因此逻辑似乎将其串联起来。但是,还是不行,所以,有人知道这样做的方法吗?
谢谢
<%= link_to "Profile", edit_user_path(current_user), :class =>"ttooltip", :data => {:url => "/users/#{@current_user}/links"} %>
您正在插入当前用户对象的字符串,这将在用户对象上调用 .to_s,这可能不是您想要的。
如果链接嵌套在每个用户下,您通常遵循 'users/:id/links' 因此您需要插入 id 而不是用户对象,如下所示:
<%= link_to "Profile", edit_user_path(current_user), :class =>"ttooltip", :data => {:url => "/users/#{current_user.id}/links"} %>
(其中 current_user 是 returns current_user 对象的辅助方法。)