I'm new to Rails, coming from Python (Django) and PHP (Zend), and have
an issue trying to move my application from development to production.
It's a little mysterious to me, but I'm sure it's something simple
that I've completely overlooked.
Without getting to in depth, I'm comfortable with developing, but I'm
taking the steps in moving applications from my development machine to
a virtual production machine. The Production machine is a Debian Lenny
box running ruby 1.8.7, Rails 2.3.4, and Mongrel 1.1.5. I've set up a
quick and simple "todo list" app for this task by running:
rails todo -d mysql
cd todo
{ mate | vim } config/database.yml
rake db:create:all
script/generate scaffold Todo title:string body:text done:boolean
due:datetime
rake db:migrate
And when I run script/server, everything runs great, and I can see no
errors in the logs. If I evoke mongrel_rails directly on the
application by:
sudo mongrel_rails start -e development -p 8000 -a 127.0.0.1 -P tmp/
pids/mongrel-1.pid
I get the exact same effect (as I understand I am essentially doing
the same thing as script/server). But when I evoke mongrel_rails to
run as production:
sudo mongrel_rails start -e production -p 8000 -a 127.0.0.1 -P tmp/
pids/mongrel-1.pid
Then I can pull up the public/index.html with no problem, but
navigating to http://example.com/todos I'll get the dreaded "We're
sorry, but something went wrong. (500)" page, and my log/
production.log delivers:
ActiveRecord::StatementInvalid (Mysql::Error: Table
'todo_production.todos' doesn't exist: SELECT * FROM `todos` ):
app/controllers/todos_controller.rb:5:in `index'
Rendering /var/rails/todo/public/500.html (500 Internal Server Error)
Which can be confirmed by opening up the production database,
todo_production, and noting that it is empty. What have I overlooked?
Note: the todo app is borrowed from: http://robmayhew.com/rails-201-todo-list-tutorial/