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.”

4 Comments »

  1. 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.

  2. 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

  3. Aaron said,

    March 1, 2010 @ 6:24 am

    Thanks!
    My issue was with haml. For some reason erb works as expected but haml fails.
    I was having problems still even with the change in the config.ru :view variable.
    I am really still not so sure on my app path situation, this is my first ruby app.
    but anyway, your first solution worked for me.

  4. Sean said,

    March 9, 2010 @ 11:05 pm

    @Aaron — I just had the same issue with my first attempt to deploy a test Sinatra app on Dreamhost; even my test app was having problems with haml. I was able to fix it by vendoring haml (run ‘gem unpack haml’; upload the results to your webroot/vendor/, and use ‘require “vendor/haml-x.x.x/lib/haml.rb”‘ instead of just ‘require “haml”‘).

RSS feed for comments on this post · TrackBack URI

Leave a Comment