title: How to integrate Alexa Rank API/gem with Ruby on Rails?
body: <p>I'm new to rails. I'm trying to integrate Alexa Rank API into my application. I don't know how to proceed? I did my best here, and it gives error:-  </p>
  
  <p>NameError: undefined local variable or method `access_key_id' for   #</p>
  
  <p>Any one tell me , how to consume a third party API like this into rails   application. It would be greatful.I need to build a web ranking site with graph analysis.</p>
  
  <p>Here is my code:-
     Client.rb</p>
  
  <pre><code>class Client &lt; ActiveRecord::Base
    attr_reader :access_key_id, :secret_access_key
  
  def self.find_rank(site_name)
      look_rank = Alexa::Client.new(access_key_id , secret_access_key).url_info(url: site_name)
      return nil unless look_rank.rank
  
      new_rank=new(name: look_rank.site_title, rank: look_rank.rank_by_country)
      new_rank=new_rank.web_rank
      new_rank
  
  end
  
  def rank
      web_rank=Alexa::Client.new(access_key_id: access_key_id, 
               secret_access_key: secret_access_key).url_info(url: site_name).rank
  
     return "#{web_rank}" if web_rank 
  
  end
  </code></pre>
  
  <p>end</p>
  
  <p>Here is Alexa rank gem code:-
     <strong>Url Info:-</strong></p>
  
  <pre><code>  client = Alexa::Client.new(access_key_id: "key",   
  
                      secret_access_key:"secret")
    url_info = client.url_info(url: "site.com")
   Method Names:- rank, site_title, keywords etc..
  </code></pre>