App is running smoothly in development mode, but deploying it onto a managed server brings up the public/500.html pag开发者_如何学JAVAe ("We're sorry, but something went wrong"), seemingly when content queries the mysql database. Putting up static content works, puzzlingly dynamic content only works locally in dev.
rake db:migrate went properly, I've manually inserted a test entry into the mysql database.
Yet requesting the view results in 500 and the log gives
ActionView::Template::Error (NULL pointer given):
10: ...
11: <% @projects.each do |project| %>
12: ...
Server runs MySQL 5.1.54, Rails has mysql gem installed. Any hints appreciated!
edit:
So I just started
rails c production
on the remote server and created an entry in my "Client" model:
irb(main):003:0> c = Client.new
=> #<Client id: nil, name: nil, permalink: nil, created_at: nil, updated_at: nil>
irb(main):004:0> c.name = "realclient"
=> "realclient"
irb(main):005:0> c
=> #<Client id: nil, name: "realclient", permalink: nil, created_at: nil, updated_at: nil>
irb(main):006:0> c.save
=> true
While all fields except for name are displayed empty in irb, the actual DB on the server show all repective fields okay:
2 realclient realclient 2011-04-22 13:59:12 2011-04-22 13:59:12
(id, name, permalink, created, updated)
So bottom line: Active Record cannot receive values correctly from the DB that are actually there?
When you ran rake db:migrate
you probably did not have a RAILS_ENV
set and so were still running in development environment. Try running:
RAILS_ENV=production rake db:migrate
See if you get an error then, and if so you can re-run it with the --trace
option for more detail.
You probably need to debug this issue on your config/database.yml
- there'll be something missing or misconfigured in the production section (or maybe you haven't created the DB or something, I'm not familiar with that specific error message).
** Solved **
My hosting provider only allows use of their pre-installed mysql 2.7 gem. Any manual loading of a mysql gem in Gemfile results in Active Record errors – even loading an own 2.7 version on top. Sticking to the default gem on the managed server works.
Setting up a new database individually on the server could probably enable use of custom database gems. So while this was a very specific problem, maybe the answer helps somebody else working with rails on a managed server.
精彩评论