JSON Parse适用于localhost,但不适用于Heroku

时间:2014-10-16 23:43:47

标签: ruby-on-rails json api heroku

JSON Parse Controller可以在我的本地计算机上运行,​​但不能在我上传到Heroku时运行。尝试运行时,Heroku错误日志中没有错误,但是当我尝试“捆绑exec heroku restart”时,我确实收到了以下错误

acpk-air% bundle exec heroku restart    
Could not find json-1.8.1 in any of the sources
Run `bundle install` to install missing gems.

运行捆绑安装没有帮助。

适用于localhost但不适用于生产的代码:

require 'rubygems'
require 'json'
require 'net/http'

class MeetupController < ApplicationController

    respond_to :json
    $meetupRI = ENV["MEETUP_API_URL"]

    def getEvents
        response = Net::HTTP.get_response(URI.parse($meetupRI))
        data = response.body
        parsed_response = JSON.parse(data)
        parsed_response["results"].each do |event|
            if Event.where(:foreign_id => event["id"]).blank?
                if event["venue"].blank?
                    e = Event.new(:name => event["name"], :description => event["description"], :url => event["event_url"], :start_time => DateTime.strptime(event['time'].to_s,'%Q'), :foreign_id => event["id"])
                else
                    e = Event.new(:name => event["name"], :description => event["description"], :url => event["event_url"], :start_time => DateTime.strptime(event['time'].to_s,'%Q'), :foreign_id => event["id"], :location => event["venue"]["name"])
                end
                e.save
            end
        end
    end
end

1 个答案:

答案 0 :(得分:0)

猜猜我昨天累了。我忘了包括:ruby&#39; 2.1.3&#39;在Gemfile中。