耙子中止! LoadError:无法加载这样的文件 - httparty

问题描述:

我在我的seed.rb文件中的以下内容:耙子中止! LoadError:无法加载这样的文件 - httparty

require 'httparty' 
require 'nokogiri' 
require 'awesome_print' 

BASE_URL = "http://www.legacy.com/funeral-homes/" 
URL_PATH = "directory/" 

def get_states(key, value) 
    arry = [] 
    i = 1 
    while i <= value do 

    response = HTTParty.get(BASE_URL + URL_PATH + "#{key}" + "?page=#{i}") 
    page = Nokogiri::HTML(response.body) 

    rows = (page.css("div.fhlistitem").select { 
     |e| !e.content.squeeze(" ").strip.empty? }).map { 
     |e| [e.css('div.fhname a').first['href'], 
      e.content.squeeze("").strip.split("\r\n").compact ] 
    } 

     rows.each do |row| 
     row[1].delete(" ") 

     hash = { 
      "name"  => row[1][0].strip, 
      "address" => row[1][1].strip, 
      "phone" => row[1][4].nil? ? "" : row[1][4].strip, 
      "email" => row[1][5].nil? ? "" : row[1][5].strip, 
      "license" => row[1][6], 
      "url"  => row[0] 
     } 

     arry << hash 

     end 

     i += 1 

    end 

    arry 

end 

fhs = get_states("alaska", 4) 

fhs.each do |fh| 
    FuneralHome.create( 
    name:  fh["name"], 
    address: fh["address"], 
    phone:  fh["phone"], 
    email:  fh["email"], 
    license: fh["license"], 
    url:  fh["url"], 
) 
end 

当我运行耙分贝:种子我得到以下错误:

WARN: Unresolved specs during Gem::Specification.reset: 
    mini_portile (~> 0.6.0) 
WARN: Clearing out unresolved specs. 
Please report a bug if this causes problems. 
rake aborted! 
Don't know how to build task 'db:seet' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/task_manager.rb:62:in `[]' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:149:in `invoke_task' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block (2 levels) in top_level' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `each' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:106:in `block in top_level' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:115:in `run_with_threads' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:100:in `top_level' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:78:in `block in run' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/lib/rake/application.rb:75:in `run' 
/usr/local/lib/ruby/gems/2.1.0/gems/rake-10.3.2/bin/rake:33:in `<top (required)>' 
/usr/local/bin/rake:23:in `load' 
/usr/local/bin/rake:23:in `<main>' 

我不知道如何解释错误。我在文件中要求'httparty'。我如何在我的seed.rb文件中运行HTTParty GET请求?或者是更好的选择?

+1

你有'httparty'安装宝石? – August 2014-11-20 23:00:14

Don't know how to build task 'db:seet' 

也许这是一个问题:尝试使用“耙分贝:种子”,而不是“耙分贝:SEET”