In place editing for multiple tags in rails 4 app

122 Views Asked by At

I'm trying to get in place editing working for multiple tags in a rails app. I'm using the best_in_place gem for this, currently I have the code below & it works fine for a single tag. Is there a way to use best_in_place to handle multiple tags.

I'd like to be able to add more tags and edit them 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" %>

Thanks!

1

There are 1 best solutions below

0
kparekh01 On

From the github documentation which you can view here(https://github.com/bernat/best_in_place), it looks like you can use :select and :collection to accomplish what you need. From the github docs:

<%= 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']] %>