# Moving my app from Development to Production

**URL:** <https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420>\
**Category:** Rails\
**Created:** [November 4, 2009, 10:42am UTC](https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420 "2009-11-04T10:42:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![H.P.L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@H.P.L](https://www.ruby-forum.com/u/H.P.L)\
**Post date:** [November 4, 2009, 10:42am UTC](https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420/1 "2009-11-04T10:42:05Z")

</div>

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](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/](http://robmayhew.com/rails-201-todo-list-tutorial/)

---

<div class="post-metadata">

**Author:** ![H.P.L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@H.P.L](https://www.ruby-forum.com/u/H.P.L)\
**Post date:** [November 4, 2009, 10:56am UTC](https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420/2 "2009-11-04T10:56:08Z")

</div>

On Tue, Nov 3, 2009 at 11:27 PM, H.P.L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> quick and simple “todo list” app for this task by running:  
> application by:  
> navigating to [http://example.com/todos](http://example.com/todos) I’ll get the dreaded "We’re  
> todo\_production, and noting that it is empty. What have I overlooked?  
> Apparantly nothing, rake db:create:all should create all you databases  
> defined on config/database.yml  
> Are you sure the specified production configuration is a valid  
> configuration?  
> Have you tried?:  
> rake db:create RAILS\_ENV=production

Hope it helps.

–  
Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![H.P.L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@H.P.L](https://www.ruby-forum.com/u/H.P.L)\
**Post date:** [November 4, 2009, 11:24am UTC](https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420/3 "2009-11-04T11:24:50Z")

</div>

H.P.L. wrote:

> 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

You’ve created all three databases here (Prod,Dev,Test) but they are  
empty.

You’ve then populated the dev database with “rake db:migrate”

> ActiveRecord::StatementInvalid (Mysql::Error: Table  
> ‘todo\_production.todos’ doesn’t exist: SELECT \* FROM `todos` ):  
> app/controllers/todos\_controller.rb:5:in `index’

The table todos doesn’t exist as it hasn’t been created.

Anthony

---

<div class="post-metadata">

**Author:** ![H.P.L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@H.P.L](https://www.ruby-forum.com/u/H.P.L)\
**Post date:** [November 4, 2009, 11:32am UTC](https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420/4 "2009-11-04T11:32:27Z")

</div>

On Wed, Nov 4, 2009 at 11:25 AM, Anthony M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > navigating to [http://example.com/todos](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’
> 
> The table todos doesn’t exist as it hasn’t been created.  
> That’s totally true, I messed that point before. You need to run:  
> rake db:migrate RAILS\_ENV=production

–  
Leonardo M…  
There’s no place like ~

---

<div class="post-metadata">

**Author:** ![H.P.L](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecb155/32.png) [@H.P.L](https://www.ruby-forum.com/u/H.P.L)\
**Post date:** [November 4, 2009, 12:16pm UTC](https://www.ruby-forum.com/t/moving-my-app-from-development-to-production/178420/5 "2009-11-04T12:16:30Z")

</div>

Leonardo M. wrote:  
[…]

> That’s totally true, I messed that point before. You need to run:  
> rake db:migrate RAILS\_ENV=production

Not quite. Migrations shouldn’t be used to create a database from  
scratch (if there are more than one or two migrations to run). For this  
case, then, you may want rake db:schema:load.

> –  
> Leonardo M…  
> There’s no place like ~

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
