I have problems installing any Ruby On Rails app on my shared hosted server. Mongrel shows html as plain text for all pages. The problem occurs for any app, even if I create a test empty app and add a scaffolded view without changing anything.
It appears that the Mongrel crashes when trying to put cookies to the response header. The HTTP header looks incomplete, the Content-type and other parameters are missing:
curl 127.0.0.1:12002/users -I
HTTP/1.1 200 OK
Connection: close
Date: Wed, 26 May 2010 09:46:50 GMT
Content-Length: 0
Here is the output from mongrel.log
Error calling Dispatcher.dispatch #<NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluati开发者_如何学Cng nil.[]>
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:108:in `send_cookies'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:136:in `out'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_response.rb:65:in `start'
ruby 1.8.7 rails 2.3.8 mongrel 1.1.5
Here is the link to the test page.
Has anyone seen anything like this?
This workaround fixed mine: https://rails.lighthouseapp.com/projects/8994/tickets/4690#ticket-4690-23
It is basically adding this mongrel.rb under config/initializers
http://gist.github.com/471663
In my case, this exact problem occurred when running mongrel with the "mongrel_rails" command. Using "script/server" command (which also launches mongrel if it's present) solved the issue.
Maybe you could write to your webhosting provider to check on this.
I posted a solution here:
https://rails.lighthouseapp.com/projects/8994/tickets/4690
Let me know if it works for you.
Thanks, Mike C
精彩评论