Floating point exception: 8 on ruby sinatra with ibm_db gem - ruby

I am getting
Floating point exception: 8
with no further description, the program just fails
when I run it as test from rspec, everything is fine, but when I run it as a method from route endpoint, it fails
post '/test' do
test_code
end
is there any way to catch more meaning full error than that? How to do that?
test code just do regular database connection and inserts data. As I stated, works ok when alone, but not from sinatra.
I am calling endpoint from Postman.
Did you encounter something similar?
If you need more detail, please ask.
Thank you for help.
specs:
ruby 2.3.3, sinatra 2+, ibm_db 3.0.5 with arel 8.0.0, os x 10.14.6

Related

Getting Paperclip::AdapterRegistry::NoHandlerError when using Padrino

I've been getting an issue where when using Padrino and paperclip whenever I try to upload an image I get the error
Paperclip::AdapterRegistry::NoHandlerError
What's going wrong?
For those wondering, the multipart form thing mentioned in many other posts is also true. See Other SO posts
All of those relate to Rails and specifically if you are using Padrino or another rack based application, you need to add one more thing or else it won't work
The exception being thrown was due to the uploaded file being represented by a Hash (Rack converts it into a Hash), and that Paperclip does not provide an adapter for this Rack specific Hash out of the box.
You need to install this gem:
gem 'paperclip-rack', require: 'paperclip/rack'

erase_results and retry in rails 3.1.3

The below code works in Rails 2.3.5, but I cannot get it to work in Rails 3.1.3:
rescue ActionController::DoubleRenderError
erase_results
retry
end
Any ideas?
erase_results was deprecated in Rails 2.3.8. You may want to try another option depending on what you are looking to do.

How to make Sinatra sessions persist across POSTs in tests?

In the following code from Learn Ruby the Hard Way : https://gist.github.com/1696733 the session seems to disappear after going through the 'post' in tests (run ruby test_gothonweb.rb to see what I mean). If I actually visit the site with my browser everything works correctly, but I would like to be able to test the site without visiting every page. What are the possible reasons for the sessions disappearing in tests?
There are a few questions coming close to this problem, but most of them are solved by not using shotgun. I am not using shotgun. I am just using regular ruby.
Versions:
ruby: 1.9.2
sinatra : 1.3.2
rack: 1.4.0 1.4.1
rack-test: 0.6.1
EDIT
I am also disabling the sessions while testing as per http://benprew.posterous.com/testing-sessions-with-sinatra - the first test using sessions with GET does work in that case (but not the POST one).
There is a known issue with rack 1.4.0. Update the gem to 1.4.1

MongoMapper in a custom gem with rspec

Hopefully I'm just missing something simple. I am using mongomapper in a rails 3 app and it works beautifully. I needed to share it with another app and pushed it out to a gem, which also works great from both rails apps. However, when I try to add rspec tests to the gem I am getting the following error:
/Users/dane/.rvm/gems/ruby-1.9.2-p180/gems/rspec-core-2.5.2/lib/rspec/core/backward_compatibility.rb:20:in `const_missing': uninitialized constant User::MongoMapper (NameError)
I am adding a really simple test for my User model.
Thanks!

twitter gem not working in heroku?

I'm working on a ruby app that updates a twitter account using 'twitter' gem. It's working fine locally (as usual :) ). But when I deploy it on heroku it seems the gem is not properly installed or something lile that as I got the following error:
NameError: uninitialized constant Twitter::OAuth
My code is very simple:
oauth = Twitter::OAuth.new(consumer_token, consumer_secret)
oauth.authorize_from_access(access_token, access_secret)
client = Twitter::Base.new(oauth)
client.update("Updating my status from twitter gem. GREAT!")
Is there a problem with this particular gem ?
Thanks a lot for your help.
Luc
Have you created a .gems file and put twitter in it?
Depending on which heroku 'stack' you are on, you may need to do that instead of a bundler Gemfile. You can change your stack for one that uses bundler by doing this:
heroku stack:migrate bamboo-ree-1.8.7
Which makes bundler available (I think).
That is a common message that usually implies that you have a discrepancy between your local gems and the gems in heroku. If you are not using Bundler yet, you should. You will end un writing a very simple Gemfile that will tell Heroku (or any other entity using your code) which gems and versions you require.
http://gembundler.com/
I would suggest that you should use the heroku addon called 'apigee', ut makes twitter on heroku simple:
http://addons.heroku.com/apigee
I just got a sinatra app talking to Twitter through Heroku/Apigee, my rate limit went from 300 calls per hour to 20,000 calls per hour. Here's a step by step on what to do:
http://geeks.aretotally.in/mind/2011/1/8/increasing-api-limits-on-a-sinatra-twitter-app-with-twitter_.html
I am really a Java developer just playing around with Sinatra but let me know if I can help in anything.
Felipe

Resources