I have a simple API called wrapped in my lib/
lib/riotapi.rb
class RiotApi
riot_url = 'https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/RiotSchmick?api_key=ENV['mykey']'
def unique_url
response = HTTParty.get(riot_url)
json = JSON.parse(response.body)
json
end
end
my controller
class WelcomeController < ApplicationController
require 'riotapi'
def index
api = RiotApi.new()
@list = api.unique_url
end
end
I have my welcome#index as the index page of the application. When I open it up, it says that undefined local variable or method "riot_url"
What am I doing wrong here?
Edit: The above sample is taken from here Very Basic Rails 4.1 API Call using HTTParty
'