Error block not working in Sinatra app - sinatra

I have the following Sinatra app and I am testing the error block but it doesnt seem to be working.
Here's my sinatra app:
require 'rubygems'
require 'sinatra'
error do
puts "----> Failed"
$stdout.print "----> Failed"
end
get "/*" do
raise "Error!!"
end
I am using sinatra (1.3.3)

You can add:
set :show_exceptions, false
To your application file.
In development environments show_exceptions is enabled by default.

Sinatra uses its own error handler when it is set in development mode, which it is by default. For your error to show up you have to run your app in production mode like this:
ruby my_app.rb -e production
Here's a link to the specific documentation for further reference:
Sinatra README #Environments

make sure you are not using the beta version of rack
gem list rack
if you see something like the following:
rack-1.6.0.beta
Uninstall this version and use the previous version rack-1.5.2

Related

Cordova native calls not working when deploying meteor on my own server

I have my meteor app with cordova running fine on meteor.com. However when I run it on my own server, the native calls fail to work. Any idea on the correct ENV variables in order for it to work fine?
http://www.meteorpedia.com/read/Environment_Variables#Environment
Edited: As requested, I'll be more clear.
I create a "Hello world" meteor app and deploy it to myapp.meteor.com
Using MeteorRider I integrate it with Cordova/Phonegap
I add a native plug-in to cordova, let's say org.apache.cordova.vibration
I call it from Meteor "navigator.notification.vibrate();"
I load it on my iPhone. Everything works as expected.
Now I want to run meteor on my own server. I create a meteor bundle, unpack it and run it with this sh:
#/bin/sh
cd /root
export MONGO_URL=mongodb://localhost:27017/wc
export PORT=3000
export ROOT_URL=http://123.456.789.000:3000/
#export METEOR_SETTINGS=$(<settings.json)
forever start bundle/main.js
I change the meteor url to my ROOT_URL and everything works except the native calls. ie navigator.notification.vibrate() fails
I have found the answer myself. I am posting this here as it might help others. This is what I was using on my index.html to configure MeteorRider.
Everything works, except plug-in calls:
var __MeteorRiderConfig__ = {
meteorUrl: "http://123.456.789.000:3000/",
phonegapVersion: 3.3,
phonegapAppVersion: 1.01
};
Everything works, including plug-in native calls:
var __MeteorRiderConfig__ = {
meteorUrl: "http://123.456.789.000:3000",
phonegapVersion: 3.3,
phonegapAppVersion: 1.01
};
Notice the difference? Yeah, right :)

Redmine plugin install (RedmineCRM Finance) results in 503

So my problem is that for some some reason installation of some plugins kills my bitnami redmine "permanently" (thin_redmine and thin_redmine2 stops after like 5 seconds).
The plugin which most recently did this is Finance Plugin from RedmineCRM. Version should be okay.
http://www.redmine.org/plugins/finance
Method I used (note that I added :migrate in the second line compared to their website (Is this the problem?)):
bundle install --without development test
bundle exec rake redmine:plugins:migrate NAME=redmine_finance RAILS_ENV=production
Am I missing or wrongly doing something? (Please note that I'm not really an expert in this field so I mainly go after how to-s.)
Are there anymore prerequirements for this (besides a very basic working redmine) e.g. I did not set up e-mail notifications, can stuff like this cause the problem?
Unfreez the gemfile. It solved the problem.

Heroku looking for erb templates but only use HAML

I'm getting a ActionView::Template::Error (undefined local variable or methodmessage_body' for #<#:0x000000041d3630>):error when I try to visitpolls/new.`
Heroku is looking for app/views/polls/new.html.erb:4:in_app_views_polls_new_html_erb__3114063437380502326_34508300'`but that file isn't even in my app. All my views are in HAML.
Any tips here would be really really helpful!
The problem might be - 'haml-rails' inside :assets or any other group in Gemfile
Move gem "haml-rails" to outside of group and it will work fine.

symfony2 locale and deployment

I am in the proces of creating a web application in symfony2. I have done all the development locally(OSX), but now I want to show a first version in a presentation where I can not use my own laptop.
I am deploying to an ubuntu 10 server. I also tested it on another small ubuntu 11 vps, but got the same problems.
I double checked with this tutorial whether php is set up correctly for symfony on my ubuntu server:
http://www.joelverhagen.com/blog/2011/05/how-to-configure-symfony-2-0-on-ubuntu-server-2011-4/
For deployment I followed these steps:
Moving app to production mode in Symfony 2
However the first step ( php app/console cache:clear --env=prod --no-debug ) gives me following error (this error also occurs when running this command locally):
php app/console cache:clear --env=prod --no-debug
Clearing the cache for the prod environment with debug false
[ReflectionException]
Class Packed\Bundle\UserBundle\Entity\Rapport does not exist
cache:clear [--no-warmup] [--no-optional-warmers]
Which is a bit weird since Packed\Bundle\UserBundle\Entity\Rapport does not exist, Packed\Bundle\ScoreModelBundle\Entity\Rapport however does.
since the app doe not need to go into production for some time this is not very urgent, what is very urgent is to get it running in development mode, so I tried using it through app_dev.php.
If I remove the localhost-check in app_dev.php everything works as expected but the i8n is not working... I can not switch to other locales as was possible locally:
xxx.com/app_dev.php/en
And it does not use the messages.nl.yml, messages.en.yml, ... and other files.
Any idea what might be causing this?
I checked the symfony and apache log but nothing weird there. Any other logs I should check?
Thanks!
Joris
Try to rebuild your bootstrap file. If you're using APC-cache restart it from cli. If it doesn't help.
Easiest way to do it is run composer and do the update.
To check the translations (the templates should be cached on the server) check the config.yml translator service must be enabled there. You may have it enabled in config_dev.yml but not in the config_prod.yml

Sinatra on Passenger always fails on first attempt

I have a small Sinatra app I'm running on a shared hosting account using Passenger. However, the first time the app is accessed after a while, I get a Passenger error page saying the application could not be started. Usually because Sinatra could not be found.
I am assuming this is just a normal delay from when a new instance is spawned. However, is there a way to delay trying to load Siantra until it Passenger has fully loaded?
I seem to have solved the issue by setting the GEMS_PATH environment variable in the .htaccess file. I haven't encountered the error again. YET!
I took this up with Dreamhost support recently (not a great experience) and eventually they recommended freezing the gems into the application. This is at best a partial solution, because it seems to work for some gems and not for others.
Instead of
require 'sinatra'
I have:
require 'vendor/gems/sinatra-0.9.4/lib/sinatra'
Freezing gems is covered elsewhere, but briefly: to prepare for this, one needs to do
mkdir vendor/gems
cd vendor/gems
gem unpack sinatra
As a result of this change, I never get the startup failure screen quoting sinatra as the file it can't load. However, I still get it for some other gems which require themselves or parts of other gems. Not too clear about the details, but I'm working on the idea of hacking the installed gems to make every "require" use a path directly out of my "vendor" library.
I think you may need to add Gem.clear_paths! in there
I had a similar problem a long time ago. Updating to a newer Sinatra gem helped me - what version are you running?