【问题标题】:In place editing for multiple tags in rails 4 app在 Rails 4 应用程序中对多个标签进行就地编辑
【发布时间】:2017-07-17 14:05:56
【问题描述】:

我正在尝试在 Rails 应用程序中为多个标签进行编辑工作。我为此使用了 best_in_place gem,目前我有下面的代码,它适用于单个标签。有没有办法使用 best_in_place 来处理多个标签。

我希望能够添加更多标签并就地编辑它们

<%= best_in_place user, :tag_test, value: friend.tag_test, place_holder: "add tag", :class => "tags btn btn-flat btn-xs btn-link" %>

谢谢!

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-4 best-in-place


    【解决方案1】:

    从您可以在此处查看的 github 文档 (https://github.com/bernat/best_in_place) 看来,您可以使用 :select:collection 来完成您需要的工作。来自 github 文档:

    <%= best_in_place @user, :country, :as => :select, :collection => {"1" => "Spain", "2" => "Italy", "3" => "Germany", "4" => "France"} %>
    <%= best_in_place @user, :country, :as => :select, :collection => { es: 'Spain', it: 'Italy', de: 'Germany', fr: 'France' } %>
    <%= best_in_place @user, :country, :as => :select, :collection => %w(Spain Italy Germany France) %>
    <%= best_in_place @user, :country, :as => :select, :collection => [[1, 'Spain'], [3, 'Germany'], [2, 'Italy'], [4, 'France']] %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-24
      • 1970-01-01
      相关资源
      最近更新 更多