Class: Spree::Admin::CountriesController
- Inherits:
-
BaseController
- Object
- BaseController
- BaseController
- Spree::Admin::CountriesController
- Defined in:
- app/controllers/spree/admin/countries_controller.rb
Constant Summary
Constants included from LocaleConcern
LocaleConcern::ADMIN_LOCALE_COOKIE
Instance Method Summary collapse
-
#select_options ⇒ Object
Returns every accessible country, sorted by its localized name.
Methods included from BreadcrumbConcern
#add_breadcrumb_icon_instance_var
Instance Method Details
#select_options ⇒ Object
Returns every accessible country, sorted by its localized name. The set is small and fixed, so the admin autocomplete loads the full list once and filters it client-side (in the admin UI locale) rather than querying the server per keystroke.
name is the underlying value used for filtering (the stored English
country name); label is the localized, flag-prefixed display string.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/spree/admin/countries_controller.rb', line 11 def countries = Spree::Country.accessible_by(current_ability, :show). sort_by(&:localized_name) = countries.map do |country| { id: country.id, name: country.name, label: country.option_label } end render json: end |