TorqueBox Vagrant Box Updated to Beta20

Thursday, July 08

Hot on the heels of the TorqueBox Beta20 release, I’ve pushed an updated version of the TorqueBox Vagrant box. The box is now 1.6GB in size - I’m not entirely sure why it’s larger than last time but if I figure it out I’ll upload a smaller version.

Grab it here:

http://bbrowning-boxes.s3.amazonaws.com/torquebox-1.0.0.Beta20.box?torrent (bittorrent)

http://bbrowning-boxes.s3.amazonaws.com/torquebox-1.0.0.Beta20.box (direct download)

Refer to my previous post for details on getting started with TorqueBox and Vagrant.

Developing Rails Apps with TorqueBox and Vagrant

Sunday, June 06

The TorqueBox project does a great job of bringing together the best parts of Ruby, Rails, JBoss, and the JVM. However, I’ve recently started using Vagrant for all my development work and couldn’t find anyone that had used the two together. So, after hacking around a bit, I’ve created a Vagrant box anyone can use to easily get up and running with TorqueBox.

The rest of this post assumes a basic level of familiarity with TorqueBox and Vagrant - things will make more sense if you browse some of their documention before reading further.

What’s Included in the Box

  • Ubuntu 8.04
  • OpenJDK 1.6.0_0-b11
  • TorqueBox 1.0.0.Beta19

Because it contains a full TorqueBox binary and a Java runtime, the box is 1.2GB in size.

Creating Your First Project

  • Add the TorqueBox Box to Vagrant

    Preferred Method - Bittorrent

    Use your favorite Bittorrent client to download http://bbrowning-boxes.s3.amazonaws.com/torquebox.box?torrent and then run

      $ vagrant box add torquebox path_to_downloaded_file/torquebox.box 

    Alternate Method - Direct Download

    The direct download will be faster (but cost me more money) unless several nice people help me seed the torrent.

      $ vagrant box add torquebox http://bbrowning-boxes.s3.amazonaws.com/torquebox.box
  • Create and initialize a sample application

      $ mkdir sample_app
      $ cd sample_app
      $ vagrant init torquebox
  • Run the box

      $ vagrant up

    This step may take a few minutes.

  • Create a Rails project

    To simplify things, all rails/rake commands should be run from inside the TorqueBox VM.

    Log into the VM and cd to the shared vagrant folder.

      $ vagrant ssh
      $ cd /vagrant

    Follow the steps from the TorqueBox Rails documentation for creating our Rails application with the TorqueBox template:

      $ rails -m $TORQUEBOX_HOME/share/rails/template.rb .

    If you look on your host machine, you’ll see the Rails application files were created in your sample_app directory. The /vagrant directory inside your VM is a bidirectional shared-folder with the sample_app directory on your host.

    After creating a new project, you’ll need to redeploy your Rails app into TorqueBox. You only have to do this once - the VM will automatically pick up on the project the next time it’s started.

      $ rake torquebox:rails:deploy

    Wait 15-30 seconds and point your browser to http://localhost:3000. You should see the familiar Rails “Welcome aboard” page.

Congratulations, you’re now running a Rails application inside TorqueBox.

Next Steps

If you’ve made it this far, you’ve done the hard part. Use your favorite editor on your host machine to develop your Rails application like you always have. The only thing to remember is to run script/generate, rake db:migrate, etc from inside the Vagrant VM. If you try to run these on the host you most likely won’t have the right version of Rails or JRuby installed.

Changes made to your Rails project should be visible on the next page refresh just like regular Rails development. To try this, generate a simple Posts scaffold.

$ ./script/generate scaffold post title:string body:text
$ rake db:migrate

Point your browser to http://localhost:3000/posts and your should see the scaffolded post index.

When you’ve finished working on this project or need to switch to another one, issue a vagrant halt or vagrant destroy from the sample_app directory on your host. The next time you need to work on this project again, issue a vagrant up to boot everything back up. See the Vagrant docs for more details on these commands.

Let’s try it.

If you’re still logged into the VM via ssh, log out.

$ exit

Destroy the VM

$ vagrant destroy

Now re-create the VM and start it back up (will take several minutes)

$ vagrant up

Wait 15-30 seconds for TorqueBox to start up and then point your browser to http://localhost:3000/posts - your app is back right where we left off.

If you have any feedback, requests, or problems with the TorqueBox box, contact me on Twitter (@bbrowning). Enjoy!

Running Bespin on the Couch

Thursday, May 21

Sparked by a thread on the CouchDB Users mailing list with promises of beer and internet groupies, I’ve started a project to get Bespin running as a CouchApp on CouchDB. The long-term goal is to allow you to create and edit CouchApps from within Bespin, which is itself a CouchApp.

My first goal was to get Bespin’s UI functioning as a CouchApp. Except for a few small things, that’s already finished.

Here’s a few screenshots of Bespin running as a CouchApp on my local CouchDB:

Index Index Page

Help Help Menu

Dashboard Dashboard

Editor Editor

Over the next few days I’ll be focusing on porting their filesystem implementation to CouchDB and CouchApp conventions. If you’d like to get involved, fork my bespin_couch project and have at it! Also, if anyone knows how I can make the GitHub repo track upstream changes from Bespin’s Mercurial repo I’d like to get that setup so I’m not just working off of a snapshot.

I haven’t had time to integrate Disqus with the blog yet so for now if you have any comments please send me a message on GitHub or a reply to @bbrowning on Twitter.

Scribbish and Jekyll

Sunday, May 17

I really wanted a minimalistic, simple theme for my blog. After looking around a bit I settled on Scribbish, a popular theme in the Ruby world with packages for Typo, Mephisto, and WordPress. Unfortunately there’s no package for Jekyll so I decided to try and port it myself.

Both Mephisto and Jekyll use the Liquid templating engine so the port was pretty straightforward. It’s still a work-in-progress but the basics are finished.

Jekyll has an include tag to create reusable components but, unlike Mephisto’s, you can’t directly pass variables to the included file. This is fairly easy to workaround by using Liquid’s assign tag or explicitly looping over a collection of objects instead of using Mephisto’s shortcuts. For example:

Jekyll

{ % for post in site.posts % }
  { % include post.html % }
{ % endfor % }

Mephisto

{ % include 'article' with articles % }

There shouldn’t be a space between the brackets and percent signs but I had to add one for display reasons

The Jekyll include tag looks for an _includes directory at the root source directory. However, if you try to use the include tag from an already included file there’s a bug where it looks for _includes/_includes/included_file.html. To workaround this for now I just created a symlink in the _includes directory to itself.

cd _includes && ln -s . _includes

Take a look at this blog’s source, particularly the _layouts and _includes directories, if you’d like to use the Scribbish theme for your own Jekyll-based blog.

Blogging With GitHub Pages

Saturday, May 16

I’ve always wanted a place to talk about the projects I’m working on but a traditional blog just didn’t feel right. A few weeks ago I stumbled across GitHub Pages and my inner geek was instantly aroused. GitHub Pages is really just free static site hosting coupled with a tool called Jekyll to generate your site’s contents based on layouts and Markdown or Textile formatted text. This is both simple and powerful. It removes the distractions and lets me focus on what really matters - the content.

Older Posts