开发者

Rails 3 U.S. State Flag Gem?

开发者 https://www.devze.com 2023-03-13 09:44 出处:网络
Is there a gem for rails to grab state flags so I don\'t h开发者_高级运维ave to download them all? Basically what I want to happen is when a user selects submits the form, there is a picture of his st

Is there a gem for rails to grab state flags so I don't h开发者_高级运维ave to download them all? Basically what I want to happen is when a user selects submits the form, there is a picture of his state flag next to his order confirmation on the next page. Any suggestions?

Thanks in advance!


Presumably you have the user's state available as a parameter in the form submission. Perhaps then you can write a little code to use that state to look up a flag at a freely available source such as Wikipedia

i.e.

AL => http://en.wikipedia.org/wiki/File:Flag_of_Alabama.svg

That's a quick and dirty solution. If you wanted to host the flags yourself, there are plenty of single mosaic images of the flags available. A little math based on the state can give you offsets into the composite image and then you can slice and dice the piece you want out of it and render it back to the user.

0

精彩评论

暂无评论...
验证码 换一张
取 消