title: Rails don't know how to build task
body: <p>I am attempting to scrape data from a website. I am running rake from index.html.erb</p>
  
  <pre><code> &lt;% Article.run_rake("fetch_games") %&gt;
  </code></pre>
  
  <p>I have it defined in a .rb file. Here is article.rb</p>
  
  <pre><code>require 'rake'
  require 'rubygems'
  #load './lib/tasks/article_task.rake'
  
  class Article &lt; ActiveRecord::Base
  
   def self.run_rake(fetch_games)
    Rails.root + "lib/tasks/article_task.rake"
    Rake::Task["fetch_games"].invoke
   end
  end
  </code></pre>
  
  <p>And here is the rakefile itself: article_task.rake</p>
  
  <pre><code>desc "Fetch Games"
  task :fetch_games =&gt; :environment do 
  
   require 'nokogiri'
   require 'open-uri'
  
   url = "http://espn.go.com/nba/schedule"
   data = Nokogiri::HTML(open(url))
   games = data.css('.responsive-table-wrap')
  
   games.each do |game|
  
   #check for a listing
   if !game.at_css("caption").nil?
      #Date
      puts game.at_css("caption").text
   else
      puts "No Listing"   
   end
  
   #check for the team name
   if !game.at_css(".team-name").nil?
      #Team name
      puts game.at_css(".team-name").text
   else
      puts "No Games Scheduled"
   end
      #empty
      puts ""
   end
  end
  </code></pre>
  
  <p>When I run this from the terminal it pulls what I need. But when I try to run it through rails server it gives me this error:</p>
  
  <p><img src="https://i.stack.imgur.com/Klvcl.png" alt="Runtime Error"></p>
  
  <p>What am I doing wrong? New to ruby/rails btw</p>