I'm following this tutorial.
This tutorial was made with older versions of Ruby/Rails and HAML that I didn't learn yet, so I'm trying to do the exact same app but working.
Here is what the app should do, the user puts in the view :
Here is the code :
<%= form_for :player, url: players_path do |f| %>
<%= f.label :p1, "First Summoner's Name " %>
<br/>
<%= f.text_field :p1 %>
<br/>
<br/>
<%= f.label :p2, "Second Summoner's Name" %>
<br/>
<%= f.text_field :p2 %>
<br/>
<br/>
<%= f.label :c1, "Summoner One's Champion" %>
<br/>
<%= f.text_field :c1 %>
<br/>
<br/>
<%= f.label :c2, "Summoner Two's Champion" %>
<br/>
<%= f.text_field :c2 %>
<br/>
<br/>
<%= f.submit %>
<% end %>
Then I use the Riot API. The point is to calculate the winrate of each player with their respective champion. So far everything is done and works, but I can't manage to get the champs ID. In order to get this data I use this method
def self.get_champion_id(champ_name)
api = RiotApi.new
champs = api.get_champion
champs["data"]["id"]
end
My problem is that, to get the id, I need to give the method, the name of the champion (named c1 and c2 previously) but I have no idea on how to achieve that, it should look like
def self.get_champion_id(champ_name)
api = RiotApi.new
champs = api.get_champion
champs["data"]["CHAMPION_NAME"]["id"]
end
Here is the repo if you want to check the code, you can't do the api calls without a key
Thanks for any advice !
Yes than it should be
champs["data"][champ_name]["id"]