iam working on a large app built with sinatra 1.2, few days ago i upgraded sinatra gem to version 2.
after upgrading this error produce
Encoding::UndefinedConversionError - "\xD8" from ASCII-8BIT to UTF-8:
when pass param with arabic language like services/مواقع
i searched for it and i didn't found any soluation except force_encoding("UTF-8") that can't use it for all params in my app
can anyone help me on this? Thank you!
Related
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
In my Ruby/Rack app I have static characters from Chinese and Japanese, in the ruby code and HTML views. When I'm running my app, I get an exception:
Encoding::InvalidByteSequenceError at /
/my_app/index.html.erb is not valid US-ASCII
It happens only on a production server, on locally -- not.
My local machine -- Linux, remote server -- FreeBSD.
I've tried "save with encoding --> utf-8" but it didn't help.
I'm not using encode/decode function in ruby code -- those characters are just statically embedded in my files.
This might be a problem with String input encodings. Strings you receive via params for example.
I had to enforce the encoding to UTF-8 via:
"Some String".force_encoding("UTF-8")
which stopped the error messages.
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'
Today when I tried to use the RestClient in my freshly installed rails project I got an err. Then I thought I had to import it so I did require 'rest-client' and also got an err. But when I installed it in my gem file and then the problem resolved.
There is no support for rest client gem in the Rails. You can check the Gemfile. I assume you are talking about the Ruby gem, if so, you can find all related information in the documentation for rest-client gem.
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