Deploying Sinatra on DreamHost - Internal Server Error with views (RESOLVED!)
I’ve been playing around with Sinatra (it’s awesome!) and thought I’d deploy something to my mess-around DreamHost account. I followed these instructions which totally worked and was so easy. But when it came time to actually deploy my real app with real views, I got nothing but “Internal Server Error”.
Internal Server Error is not very informative, but if you’re seeing it when you’re calling views (like erb(:page)), you might need to change that to:
erb(File.read('views/page.erb'))
That stopped the errors and let my app work. Locally, there was no problem, and a cursory glance through Sinatra didn’t tell me why it worked here and not there. I guess I’m programming by accident this morning.
Update: I was able to get erb(:page) working by fixing the view path in my config.ru. In the options merged into Sinatra::Application.default_options, I added :views => '/path/to/app/views'. Before it was getting set to something like ‘path/to/app/Rack: /path/to/app/views’. tusho in #sinatra suggested that “Passenger is odd.”
Chris Schneider said,
July 7, 2008 @ 9:12 am
Awesome getting it to work! I wonder why Passenger is handing back such a weird path.
To make it more flexible, instead of hard coding ‘/path/to/app/views’, you could do a:
set :views, File.join(File.dirname(__FILE__), ‘views’)
That way you can move/redeploy your app with no problems, as all the references are local.
Jerod said,
July 23, 2008 @ 7:31 am
Thanks for this. I had the same problem when deploying my Sinatra app. Works like a charm!
I wrote a quick and dirty IP to location mapper using the Google Maps API.
http://ip2loc.jerodsanto.net