Makoto Taguchi
Makoto Taguchi

Reputation: 149

How to add country flag in options_for_select

I'm trying to add country flag using options_for_select method but no success. Can someone help?

I tried a couple of options already(example below), none of them works properly.

options_for_select(ISO3166::Country.all.map { |country| [country.name, country.alpha2, { 'class' => "flag-icon flag-icon-us"}] }.sort_by { |country| country.first }, countries)

Upvotes: 2

Views: 458

Answers (1)

lacostenycoder
lacostenycoder

Reputation: 11216

Maybe try this instead?

options_for_select(ISO3166::Country.all.map { |country| [country.name, country.alpha2, country.emoji_flag] }.sort_by { |country| country.first }, countries)

Upvotes: 1

Related Questions