Railscast geocoding missing JSON::ParserError constant - ruby-on-rails-3.1

Replicating the geocoding example from Railscast #273 at http://railscasts.com/episodes/273-geocoder
under Rails 3.1rc4 using:
multi_json (1.0.3)
nifty-generators (0.4.6)
I get
NameError in LocationsController#create
uninitialized constant JSON::ParserError
Rails.root: ...
Application Trace | Framework Trace | Full Trace
app/controllers/locations_controller.rb:20:in `create'
This error occurred while loading the following files:
multi_json/engines/json_gem
I must be missing something which defines this. Anyone have an idea?rc4

Related

ruby kafka parse error

I am trying to parse a kafka topic using Ruby.
my code :
require 'kafka'
kafka = Kafka.new(seed_brokers: ["someserver"])
kafka.each_message(topic: "topicname") do |message|
puts message.offset, message.key, message.value
end
I am getting below error:
/Users/someuser/.rbenv/versions/2.4.2/lib/ruby/2.4.0/optparse.rb:1644:in `parse!': unknown keywords: seed_brokers, client_id (ArgumentError)
from /Users/someuser/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/kafka-0.0.2/lib/kafka.rb:66:in `parse'
from /Users/someuser/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/kafka-0.0.2/lib/kafka.rb:16:in `initialize'
from KafkaConnect.rb:4:in `new'
from KafkaConnect.rb:4:in `<main>'
Not sure what is the issue, I have checked the documentation and there seems to be no problem.
I have also checked using kafkacat and it is able to stream the data without no issues. challenge is with Ruby.

Ruby rconomic gem issue: SSL connect certificate verify fail

I'm trying to utilize a gem to access my accounting site, e-conomic, via Ruby.
Gem (rconomic): https://github.com/substancelab/rconomic
The code I've used is below (where I've replaced the private app ID and the access ID with the relevant IDs):
Dir.chdir 'C:\Ruby22\bin'
require 'rconomic'
economic = Economic::Session.new
economic.connect_with_token 'the_private_app_id', 'the_access_id_you_got_from_the_grant'
However, when I run the code I receive the following error message:
C:/Ruby22/lib/ruby/gems/2.2.0/gems/httpi-2.4.2/lib/httpi/adapter/net_http.rb:51:in 'rescue in request': SSL_connect returned=1 errno=0 state=error: certificate verify failed (HTTPI::SSLError)
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httpi-2.4.2/lib/httpi/adapter/net_http.rb:33:in 'request'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httpi-2.4.2/lib/httpi.rb:161:in `request'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httpi-2.4.2/lib/httpi.rb:133:in 'post'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:94:in 'block in call_with_logging'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/request_logger.rb:12:in 'call'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/request_logger.rb:12:in 'log'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:94:in 'call_with_logging'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/operation.rb:54:in 'call'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/savon-2.11.1/lib/savon/client.rb:36:in 'call'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rconomic-0.5.2/lib/economic/endpoint.rb:74:in 'request'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rconomic-0.5.2/lib/economic/endpoint.rb:20:in 'call'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/rconomic-0.5.2/lib/economic/session.rb:22:in 'connect_with_token'
from C:/Ruby22/bin/rconomic_test.rb:8:in ''
Any ideas as to what would be causing this?
- I have tried updating my rubygems
- I am running on Windows 7 with Ruby 2.2.6
I'm a bit of a novice in Ruby, but I would really appreciate any help on this!
Best,
Martin

Problems with Passenger on Apache

I'm having troubles deploying a rack application with rack-http-logger middleware on Passenger Apache version. The problem is that Apache doesn't accept LOG method requests, which this middleware is interpreting, so I'm trying to use POST instead.
This is my config.ru:
require 'bundler'
Bundler.require
$stdout.sync = true
use Rack::HTTPLogger, :method => 'POST'
run lambda { [404, {'Content-Type' => 'text/html'}, ['Page Not Found']] }
Everything is working fine on Thin, but I'm having this error on Passenger:
App 57235 stderr: [ 2014-04-30 08:30:05.9440 57256/0x007ffe8c018af0(Worker 1) utils.rb:68 ]:
*** Exception ArgumentError in Rack application object (wrong number of arguments (1 for 0)) (process 57256, thread 0x007ffe8c018af0(Worker 1)):
App 57235 stderr: from config.ru:7:in `block (2 levels) in <main>'
App 57235 stderr: from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/rack-http-logger-0.1.0/lib/rack/http-logger.rb:17:in `call'
App 57235 stderr: from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/rack-http-logger-0.1.0/lib/rack/http-logger.rb:17:in `call'
App 57235 stderr: from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
App 57235 stderr: from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
App 57235 stderr: from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
App 57235 stderr: from /Users/apps/.rvm/gems/ruby-1.9.3-p545/gems/passenger-4.0.41/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'
[Wed Apr 30 08:30:05 2014] [error] [client 172.20.16.168] Premature end of script headers:
Any ideas of what I could be doing wrong?
Your application object (the lambda that that you pass to run) does not conform to the Rack specification. According to the specification, it must accept exactly 1 argument, but your lambda accepts none and so you get an ArgumentError.
Phusion Passenger implements Rack differently than Thin does. Because the Rack specification does not specify how spec violations should be handled, each server handles it differently. This is why some (wrong) code which works on Thin, may not work on Phusion Passenger, and vice versa.

NameError uninitialized constant in Jruy/Rails 3

I'm upgrading a project to Rails 3.1 and Jruby 1.6.4 from rails 2.6 I followed the Rails Handbook by Jeremy.
Now I'm getting some errors while booting the server.
NameError in Adm::AuthController#login
uninitialized constant Sentry::Dispatcher::Dispatcher
The error log
Started GET "/admin/login/en/sentry" for 127.0.0.1 at Wed Oct 05 16:59:00 -0400
2011
Processing by Adm::AuthController#login as HTML
Parameters: {"brand"=>"sentry", "language"=>"en"}
Completed 500 Internal Server Error in 9ms
NameError (uninitialized constant Sentry::Dispatcher::Dispatcher):
lib/sentry/dispatcher/application_dispatcher.rb:11:in `initialize'
app/controllers/application_controller.rb:90:in `before_interceptors'
Rendered C:/Users/matin/.pik/rubies/JRuby-164/lib/ruby/gems/1.8/gems/actionpack-
3.1.0/lib/action_dispatch/middleware/templates/rescues/_trace.erb (5.0ms)
Rendered C:/Users/matin/.pik/rubies/JRuby-164/lib/ruby/gems/1.8/gems/actionpack-
3.1.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
(5.0ms)
Rendered C:/Users/matin/.pik/rubies/JRuby-164/lib/ruby/gems/1.8/gems/actionpack-
3.1.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within re
scues/layout (30.0ms)
This works for me..
while upgrading you need to include the class as well, like(in this case)
include 'sentry/dispatcher/dispatcher'

problem while deploying sinatra application on heroku

I am able to deploy my basic sinatra app on heroku but running it gives "APP CRASHES" error
running "heroku logs" give the following error. I am using ruby1.9.1. dont know why this ruby1.8.7 shows in the backtrace. Please help
anmol#anmol-laptop:heroku$ heroku logs
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- sinatra (LoadError)
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from ./main.rb:2
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from config.ru:1
from /home/heroku_rack/heroku.ru:23
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in instance_eval'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininitialize'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:46:in new'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:46:inmap'
from /home/heroku_rack/heroku.ru:18
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in instance_eval'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininitialize'
from /home/heroku_rack/heroku.ru:11:in new'
from /home/heroku_rack/heroku.ru:11
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininstance_eval'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in initialize'
from /home/heroku_rack/heroku.ru:1:innew'
from /home/heroku_rack/heroku.ru:1
==> dyno-3277552.log (crash) <==
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': no such file to load -- sinatra (LoadError)
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from ./main.rb:2
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require'
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
from config.ru:1
from /home/heroku_rack/heroku.ru:23
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in instance_eval'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininitialize'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:46:in new'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:46:inmap'
from /home/heroku_rack/heroku.ru:18
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in instance_eval'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininitialize'
from /home/heroku_rack/heroku.ru:11:in new'
from /home/heroku_rack/heroku.ru:11
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininstance_eval'
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in initialize'
from /home/heroku_rack/heroku.ru:1:innew'
from /home/heroku_rack/heroku.ru:1
-----> Your application is requiring a file that it can't find.
Most often this is due to missing gems, or it could be that you failed
to commit the file to your repo. See http://docs.heroku.com/gems for
more information on managing gems.
Examine the backtrace above this message to debug.
create a file with a name ".gems" and include this line "sinatra".
by this way you are instructing to include sinatra gem
More information is here: http://docs.heroku.com/rack#sinatra

Resources