问题
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 evaluating 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?
回答1:
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
回答2:
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.
回答3:
I posted a solution here:
https://rails.lighthouseapp.com/projects/8994/tickets/4690
Let me know if it works for you.
Thanks, Mike C
来源:https://stackoverflow.com/questions/2911852/problems-running-ruby-on-rails-apps-on-shared-hosted-server