title: Why is Ruby array.each do not iterating over each item in array?
body: <p>I'm new to ruby and rails and coding in general. But I'm working on a project that uses the steam web api to get a list of games owned by a user on steam. I'm trying to take that information and store it in my own table. I was able to get the information into my site but I need to select only one part of the information to pass into my table.</p>
  <p>In my users controller I have this for show:</p>
  <pre><code> def show
       #renders the user page
       @user = User.find(params[:id])
       @player = SteamWebApi::Player.new(@user.steam_id)
   end
  </code></pre>
  <p>In the users show view I have this:</p>
  <pre><code>&lt;% user_class = User.new %&gt;
  &lt;h2&gt; These are the games you own &lt;/h2&gt;
  &lt;% @games = @player.owned_games %&gt;
  &lt;% @steam_game_ids = user_class.get_steam_id_from_games(@games) %&gt;
  &lt;br&gt;
  &lt;%= user_class.check_if_games_exit_in_table(@steam_game_ids) %&gt;
  </code></pre>
  <p>The <em>@player.owned_games</em> gives an array of games like this:
  [{&quot;appid&quot; =&gt; 1234}, &quot;something&quot; =&gt; 23123}, {&quot;appid&quot; =&gt;...}]</p>
  <p>In my users model I define these methods:</p>
  <pre><code>def get_steam_id_from_games(games)
      games.games.map{|x| x.values[0]}       
  end
  
  def check_if_games_exist_in_table(steam_ids)
      string_ids = steam_ids.map(&amp;:to_s) #not converting to string
      string_ids.each do |app_id|
          if Game.exists?(game_app_id: app_id)
              return &quot;this exists&quot;
          else
              return &quot;#{app_id} doesn't exist&quot;
          end
      end       
  end
  </code></pre>
  <p><em>get_steam_id_from_games</em> makes an array with only the appid values for each game:[1234, 234545,..]</p>
  <p><em>check_if_games_exist_in_table</em> is supposed to take the appid array, converts the items to strings (that's how I store the information in my table), and then checks if there is an object in the table with the same appid.</p>
  <p>This is where the problem is for me, the <em>string_ids.each to |app_id|</em> only goes through the first thing in the array. Is this because I'm returning &quot;this exists&quot; or &quot;doesn't exist&quot;? What can I do to fix this problem?</p>