Friday, January 31, 2014

Rails Destroy Table, Create Table, Migrate

Ever messed up your db by not using the rails destroy migration?

Instead of running the rake commands separately like so:

rake db:drop 
rake db:create
rake db:migrate

... you can stack them into one command.

rake db:drop db:create db:migrate

This way you don't have to wait for the environment to reload for each rake command.

Wednesday, January 29, 2014

Rails: A server is already running. Check /vagrant/tmp/pids/

I'm using vagrant as my virtual machine for a project and kept running into my port not shutting down completely after exiting the rails server.

vagrant@precise32:/vagrant$ rails s
=> Booting Thin
=> Rails 3.2.16 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
A server is already running. Check /vagrant/tmp/pids/

Solution was to check the port and to kill the process with the pid:

$ lsof -wni tcp:3000
ruby    12365 vagrant    9u  IPv4 114859      0t0  TCP *:3000 (LISTEN)
kill -9 12365