Ruby on rails 是否有任何方法可以使Best_In_place管理的对象也成为链接?

Ruby on rails 是否有任何方法可以使Best_In_place管理的对象也成为链接?,ruby-on-rails,ruby-on-rails-4,best-in-place,Ruby On Rails,Ruby On Rails 4,Best In Place,我在用电脑 这是我的对象的一个示例: <h5><%= best_in_place node, :name, as: :input, activator: "#edit-node-title-#{node.id}" %> <%= link_to "<i class='fa fa-pencil'></i>".html_safe, "#", id: "edit-node-title-#{node.id}" %></h5>

我在用电脑

这是我的对象的一个示例:

<h5><%= best_in_place node, :name, as: :input, activator: "#edit-node-title-#{node.id}" %> <%= link_to "<i class='fa fa-pencil'></i>".html_safe, "#", id: "edit-node-title-#{node.id}" %></h5> 

但我想做的是将
节点.name
属性显示为常规链接

所以只要
链接到node.name,node


如何将这两者结合起来?

您可以将您的
最佳位置的
标签包装在
链接\u的
标签中:

<h5>
  <%= link_to node_path(node) do %><!-- Or whatever path you want to link_to --> 
    <%= best_in_place node, :name, as: :input, activator: "#edit-node-title-#{node.id}" %>
  <% end %>
  <%= link_to "#", id: "edit-node-title-#{node.id}" do %>
    <i class='fa fa-pencil'></i>
  <% end %>
</h5>


我还编辑了你的激活器链接,所以它也是一个块。这是未经测试的,但它应该可以工作。

是否使用带有
选项的
显示?它需要一个助手或进程。我更喜欢助手,但为了简洁起见,我用proc显示它:

<%= best_in_place node, :name, as: :input, 
                               activator: "#edit-node-title-#{node.id}" 
                               display_with: proc{|node| link_to node.name, node_path(node) }
%> 
<%= link_to "<i class='fa fa-pencil'></i>".html_safe, "#", id: "edit-node-title-#{node.id}" %>

因此,助手版本只需在带有:
选项的
显示中包含助手方法的名称?例如,假设helper方法是:
link\u to\u node(node)
,我会在方法中只包含
link\u to
,然后在
display\u中包含方法的名称。您可以查看一些示例。