Just to begin with, I want to apologize for my inexpertise. I'm still in the process of learning RoR.
I'm currently attempting to practice building a semi-advanced website, which is one big step, but I've made a lot of progress.
I'm currently sitting with a problem, that I've spent days on trying to solve. I'm sure it's a little thing I'm overlooking, but I'm banging my head against the wall trying to figure it out.
I can't seem to find any video, google search, or SO thread talking well about it.
-- Country Flags --
I'm using the country_select and countries gem. According to the countries gems' page, https://github.com/hexorx/countries, it can indeed display country flag emojis. It doesn't have a wiki, but on the 'frontpage', the only info is:
c = Country['MY']
c.emoji_flag # => ""
I found a very few SO articles about displaying country flag emojis. Rails 5 - Countries gem - flags I've read this one multiple times and tried to make my own adjusements, basically running into the exact same issues that the guy has. I get the same errors.
One minor thing that does not work when I test run it, is the:
irb(main):001:0> require "countries/global"
=> true
My test, does comes back as:
irb(main):001:0> require "countries/global"
=> false
Even though my gemfile has the:
gem 'countries', :require => 'countries/global'
This article, Rails 5 - Flag Icons with dynamic country input, is not for the countries gem, but for yet another gem. There was no answer there either.
After sort of giving up on displaying my countries flag emojis through the countries gem and the limited information/guidance, I found this article: What are my options for incorporating country flags into a Rails 4 app?. There was only 1 answer.
Which led me to downloading the zipfile on https://www.flag-sprites.com/, unzip it and moved the image into my asset pipeline/images and the css files into the asset pipeline/stylesheets.
I've of course linked them, precompiled them etc.
I then attemped to test run the code to display one of the images through the sprite, using:
<span class="flag flag-us"></span>
Which shows the selected image(US flag) perfectly... But! What I really need these country flags for, are for a users profile, once they're signed in.
My users already have to choose a country, for example United States of America (US) through the signup. It also gets saved in the database, no issue there.
I simply want to add the users countrys' flag to their profile page, based on the country they've chosen when they signed up.
I currently use:
<ul>
<li><span><p>Username:</p></span> <%= current_user.username %></li>
<li><span><p>Country:</p></span> <span><%= current_user.country_name %></span></li>
<br>
<li><p>Bio:</p><p class="bio"><%= current_user.bio %></p></li>
</ul>
to display user-based information. The username tag works, it displays the users username, that they chose during signup. The country works, with full name fx: United States of America, instead of US. The bio also works. The user can go edit it through the edit page and it'll change perfectly.
But now I need to know, how to make my syntax fetch the appropiate flag, based on the country the user have selected during the signup.
I really hope I can get some help here on SO. Any help will be much appriciated. Thanks in advance.
Also apologizing for the long text of wall, just wanted to try and show some of the research I've done. I'm sure I'm missing something here, but there's very little information about this out there.
OBS! Using Windows 8.1, Ruby on Rails 5.