Rails, production environment exception page shows in development environment - ruby

I'm running Rails 4.2.0.beta and am having a weird issue; instead of the usual Rail’s page displaying exceptions in development mode, like so:
I get the following:
This page appears with any exception.
I have double checked that I'm under development mode and that 'consider_all_requests_local' is set to true in config/environments/development.rb.
I noticed I'm receiving the following error when I hit an exception
" ERROR Rack::Lint::LintError: Response body was given for HEAD request, but should be empty
/Users/Rali/.rbenv/versions/2.2.0-dev/lib/ruby/gems/2.2.0/gems/rack-1.6.0.beta/lib/rack/lint.rb:20:in `assert'"
I assume it's somehow related.. Any ideas?

Sorry for digging out a month-old question but if there is anyone with same issue (like me), though with version 4.2.0.rc1 I fixed it by removing gem 'web-console' from Gemfile which is by default added when generating new application.

Removing gem 'web-console' also solved this issue for me in Rails 5.1, for anyone stumbling into this issue 4 years later...

Related

can't get ruby omniauth-ebay-oauth gem example code working

I am trying to setup and use omniauth-ebay-oauth (https://github.com/evilmartians/omniauth-ebay-oauth) gem to use eBay rest APIs in my app without success.
I set up the required environment variables and run the example code but get a message saying "Sinatra doesn’t know this ditty.". It does not recognise the '/auth/ebay' route, not sure if I have to declare that route myself nor what to put in it if I do. I'm new to ruby and Sinatra so do apologise if this is just something silly and obvious that I'm missing.
require 'omniauth-ebay-oauth'
use Rack::Session::Cookie
use OmniAuth::Builder do
provider :ebay_oauth, ENV['EBAY_CLIENT_ID'], ENV['EBAY_CLIENT_SECRET'],
callback_url: ENV['EBAY_RU_NAME'], name: 'ebay'
end
get '/' do
redirect '/auth/ebay'
end
get '/auth/ebay/callback' do
"Hello, #{request.env['omniauth.auth'].dig('info', 'name')}"
end
I appreciate any help and insight in getting this working. I've googled everywhere and asking here as my last resort.
I opened an issue on the GitHub repository and the gem creator replied in 3 hours. Totally life saver. I will post the solution here to help others.
It is because of security settings of OmniAuth 2.x.
Add the following line at the top, after requires:
OmniAuth.config.allowed_request_methods += %i[get]
This worked like a charm and I can now move forwards with the project.

Twitter handler (sensu and ruby) troubleshooting

I'm trying to get Sensu twitter-handler working on my environment. The issue is that I'm not getting any errors on screen or logs when I cat a .json event into the twitter-handler and, the tweets are not being shown on the linked account.
Here're are my config files:
https://gist.github.com/Mariano-gon/8648427
https://gist.github.com/Mariano-gon/8648455
https://gist.github.com/Mariano-gon/8648489
This is the output I get:
https://gist.github.com/Mariano-gon/8648480
One important note is that in sensu-api.log the request are being recieved:
https://gist.github.com/Mariano-gon/8673758
So, my question is: is there a way to troubleshoot this issue? Any way to debug the handler.rb?
Thanks!
Finally got it working! Thing was the new 'twitter' gem (in my case v5.6) won't work with the code as it was written. I needed to follow this great answer and this thread too. Was just a matter of sintaxis (as usual).
Thanks!

Rails 4 - ActiveAdmin - Redactor - Heroku -- has no method 'redactor' console error

I've been trying to tackle this all morning. Locally, this setup works just fine. I am not using the redactor-rails gem because this is a rails 4 app and it doesn't support it. I have moved the redactor.css and redactor.js calls from the active_admin initializer file to be required in my actice_admin.js.coffee and active_admin.css files because on Heroku, it could not find the path. Now, when firing up the page that should be displaying redactor, I get has no method 'redactor' in the console.
I'm at a loss. I've read up on precompiling assets and the how the pipeline works, but it doesn't seem like I'm doing anything out of the ordinary here.
So how can I deploy to Heroku without this error?
Ok, so I seemed to have disregarded an important task. After thinking about precompilation a bit more I remembered I had been told to run
RAILS_ENV=production bundle exec rake assets:precompile
before. After running that again, it precompiled the active_admin.css and active_admin.js.coffee files which had the new require's in it. Viola!
Hope this helps someone else in the future.

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

Sinatra - how do I debug it when it's online?

I wrote a teeny tiny Sinatra app that runs fine, locally, but for some reason as soon as I put it online, all I get is 'Internal Server Error'.
How do I get the logging output?
I'm running on Dreamhost with passenger, using the instructions from the Sinatra book.
So I added to more handlers:
get '/hello/:name' do
"Hello, #{params[:name]}!"
end
get '/nokogiri-test/' do
doc = Nokogiri::HTML(open('http://www.google.co.il/search?q='+params[:query]))
res = ''
doc.xpath('//li//h3//a').each do |li|
res+= li.content + '<br />'
end
res
end
The first one works fine, the second throws an error.
I'm not interested in why there's an error. I'm interested in how to get feedback for it and resolve errors in the future.
Ah! The answer comes from here.
Never would have thought to look in there, but I got desperate. The solution is to set the environment to :development:
set :environment, :development
I stuck that into my configuration files and it produced all the error output.
Still doesn't solve my problem if I ever want to discover what's causing an error in a PRODUCTION app...
So how would I solve that?
If you're seeing apache's Internal Server Error message, you should be able to check the apache error log to find out what's going on. I think on dreamhost the log file is stored in /home/your_user_name/logs/yourdomain.com/http/error.log

Resources