What are my options for incorporating country flag

2019-07-27 03:56发布

问题:

Right now I am currently using the country_select gem and the countries gem with a :country column in my Users model. I want to use @user.country to show the national flag for each @user.

world-flags gem has not been updated in 4 years and is listed as being for Rails 3 and there is almost nothing on StackOverFlow about it.

Or I guess I could download these flag pngs put them in a folder on s3 and do something like this:

def flag_url 
  self[country] = /flags/"#{country}".png
end

回答1:

I think you have to try this Flag Sprites , you can integrate it with country_select gem easily, no need to store all flag on server. Hope this will help you. it's just a simple css and one image.