View All Tables – Sqlite3

Not really something that I’ve broken (yet), but definitely something I found useful when starting out with rails – how to view all tables:

Start Sqlite3 i.e.
chris@chris-VirtualBox:~/site$ sqlite3 -line db/development.sqlite3
SQLite version 3.7.4
Enter “.help” for instructions
Enter SQL statements terminated with a “;”

Then simply enter the following:
sqlite> .tables
carts message_recipients products taggings
categories message_statuses schema_migrations tags
comments messages store_pages user_settings
images order_items store_settings users
line_items orders stores
locations product_images sub_orders
sqlite>

Good Luck!

Rails Server – Address Already in Use

Well, looks like the first thing I’ve managed to break today is WEBrick – a web server for ruby on rails. The general idea behind the error message appears to be that the address it’s trying to start is already in use:

[2011-12-02 19:01:34] INFO  WEBrick 1.3.1
[2011-12-02 19:01:34] INFO  ruby 1.8.7 (2010-08-16) [i686-linux]
[2011-12-02 19:01:39] WARN  TCPServer Error: Address already in use – bind(2)
Exiting
/usr/lib/ruby/1.8/webrick/utils.rb:73:in `initialize’: Address already in use – bind(2) (Errno::EADDRINUSE)
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `new’
from /usr/lib/ruby/1.8/webrick/utils.rb:73:in `create_listeners’
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `each’
from /usr/lib/ruby/1.8/webrick/utils.rb:70:in `create_listeners’
from /usr/lib/ruby/1.8/webrick/server.rb:75:in `listen’
from /usr/lib/ruby/1.8/webrick/server.rb:63:in `initialize’
from /usr/lib/ruby/1.8/webrick/httpserver.rb:24:in `initialize’
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/handler/webrick.rb:10:in `new’
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/handler/webrick.rb:10:in `run’
from /usr/lib/ruby/gems/1.8/gems/rack-1.3.4/lib/rack/server.rb:265:in `start’
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands/server.rb:70:in `start’
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands.rb:54
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands.rb:49:in `tap’
from /usr/lib/ruby/gems/1.8/gems/railties-3.1.1/lib/rails/commands.rb:49
from script/rails:6:in `require’
from script/rails:6

 

Sure enough, it turns out that one of my previous WEBrick processes had not closed properly. I was able to view the existing processes using the following:
chris@chris-VirtualBox:~/site$ pgrep ruby
1601

 

In order to close them simply kill the process:
chris@chris-VirtualBox:~/site$ kill 1601

 

Ensure that the process is gone:
chris@chris-VirtualBox:~/site$ pgrep ruby

 

And finally, start WEBrick again.
chris@chris-VirtualBox:~/site$ rails server
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-02 19:13:21] INFO  WEBrick 1.3.1
[2011-12-02 19:13:21] INFO  ruby 1.8.7 (2010-08-16) [i686-linux]
[2011-12-02 19:13:26] INFO  WEBrick::HTTPServer#start: pid=1814 port=3000

 

Good luck!