The JSON Parse Controller works on my local computer but not when I upload it to Heroku. There are no errors in the Heroku error log when trying to run it, but I do get the error below when I try "bundle 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.
Running Bundle Install doesn't help.
Code that works on localhost but not production:
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
Guess I was tired yesterday. I forgot to include: ruby '2.1.3' in the Gemfile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.