I finally started playing with rails again. I decided to play around and start the basics of a billing application. I was initially debating web app versus a desktop app (rails vs ruby-gtk). I wanted a reason to finally start using rails so I decided to make it a web app. I then realized I may be able to simulate a desktop app with rails. I pulled in the base ruby packages, manually compiled RubyGems and installed necessary gems, and decided to script a startup routine so I could create a launcher on my desktop. This solution is far from perfect but it manages to fulfill my needs. My “desktop rails app” uses the built in standalone webserver WEBrick and sqlite3 for its backend.
#!/bin/bash cd /home/jesse/rails/billing if [ ! -f tmp/pids/server.pid ]; then script/server -d fi while [ `netstat -tan | grep 0.0.0.0:3000 | wc -l` != 1 ]; do echo "Server not started yet..." sleep 1 done google-chrome http://localhost:3000/customers & tail -f log/development.log # Server can be killed with: # kill -INT `cat tmp/pids/server.pid`
I then created a launcher simliar to this:
When I double click on the icon the first time it pauses for about 5-6 seconds while WEBrick initializes and binds to port 3000. As soon as it detects the webserver listening, I launch google-chrome to the default view. Each time I click the icon there after, the webserver is already running so the google-chrome tab kicks off instantly.
Thank you dude