How can I integrate the country_select stone with the best_in_place editing

I use best_in_place to edit inline and country_select entries to display a list of countries to select. When using best_in_place to edit the select field, I do this:

<%= best_in_place(@home, :country_name, :type => :select, :collection => [[1, "Spain"], [2, "Italy"]]) %>

Now I like to get a list of all countries that country_select has and passes this value to the collection parameter. The country_select driver provides a simple helper to display the select box:

<%= country_select("home", "country_name") %>

I would like to replace the: collection parameter in the best_in_place helper to include a list of countries provided by country_select. I know that best_in_place is waiting for input [[key, value], [key, value], ...] in: collection, but I'm not sure how to do this. Please advise. Thanks

+3
source share
2 answers

Just follow these steps:

<%= best_in_place @home, :country, type: :select, collection: (ActionView::Helpers::FormOptionsHelper::COUNTRIES.zip(ActionView::Helpers::FormOptionsHelper::COUNTRIES)) %>
+5
source

If you use rails 4 after a few years, this does the trick:

<%= best_in_place @cart.order, :country_name, type: :select, :collection =>  ActionView::Helpers::FormOptionsHelper::COUNTRIES%>
0
source

All Articles