将国旗合并到 Rails 4 应用程序中有哪些选项?

问题描述:

现在我正在使用 country_select gemcountries gem 在我的用户模型中有一个 :country 列.我想使用 @user.country 来显示每个@user 的国旗.

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 已有 4 年未更新,并被列为适用于 Rails3 并且 * 上几乎没有关于它的任何内容.

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

或者我想我可以下载这些 flag pngs 将它们放在一个文件夹中在 s3 上执行以下操作:

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

我觉得你必须试试这个 Flag Sprites ,您可以轻松地将其与 country_select gem 集成,无需将所有标志存储在服务器上.希望这会帮助你.它只是一个简单的 css 和一个图像.

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.