C’mon N’ Ride It (The Train)

Most Common Rails Commands for Use in Terminal/Console

rails new name_of_app (make a new app called “name_of_app”)
cd name_of_app (get yerself into your app directory)

rake tmp:clear (clear the cache)
rake assets:clean && rake assets:precompile && rails s (get your css house in order and start the server)
rake routes > doc/routes.txt (print all your routes to text file for easy reading)
rails s -p 3001 (start the local server on a different non-standard port, in this case port 3001)
reload! (reload rails console, rails c, without restarting)

rails generate scaffold NAME [field[:type][:index] field[:type][:index]] [options] (generate the whole shootin’ match: model, database migration for that model, controller to manipulate it, views to view and manipulate the data, and a test suite for each of the above)
rails generate migration add_column_to_table column:string (add a column, in this case a variable named column that is a string, to an existing database table; many other variables may be added and used to reduce the rewrite before performing a “rake db:migrate” in terminal to actually alter the database)
rails generate controller section_name index (add a controller; same as above with variables)

rake db:migrate (build the database using your specified migrations)
rake db:rollback (rollback last db:migrate)

bundle install (gems added to gem file entered into gem.lock)
bundle update (gems removed from gem file removed from gem.lock)


Posted in Rails && Sinatra && Camping

Git Merge Conflicts – Note to Self

<<<<<<< HEAD
code from branch you are on
conflicting code from branch you are pulling/merging in
>>>>>>> 66f9_long_id_code_goes_here_536299efa982fa

Posted in Vocation & Profession, Web

Social Media Management

An Organizational Structure That Supports Your Digital Presence (Check the awesome responsibility matrix!) Go here: http://ow.ly/n8SVo



Posted in Amusement

Setting Up an AWS Server

It you haven’t been playing along a home, you might want to start now. It’s easy and cheap-free on the micro instance. In the words of E2C for Poets, this is what it is all about:

There’s this great service called EC2 run by Amazon, the same Amazon you can buy books and refrigerators from.

EC2 allows you to create your own server in Amazon’s server farm located somewhere “up there” in the clouds. It could be in Montana or New Jersey or Europe. You don’t have to know or care where the server is.

You also don’t have to talk to anyone to create a server. And when you’re done with it, just shut it off. You only pay for what you use. And it doesn’t cost very much. If you run a server for 8 hours it costs about $1. Update: For some people it’s free for a year!

If you’ve ever purchased anything at Amazon, you’re all set. And if you haven’t, all you need is a credit card.

I think any reasonably knowledgeable user could set up a server this way. You might have to scratch your head, or read the instructions two or three times to get past the hardest parts. But you don’t have to be an math major to pull it off.

Let’s do this thing.


  1. account at Amazon
  2. desktop or laptop computer
  3. 10-60 minutes

Login to AWS

  1. go to http://aws.amazon.com/
  2. create a free account
  3. login!

Sign up for S3 (storage) and EC2 (a server)

  1. go to http://aws.amazon.com/s3/ for storage space
  2. go to http://aws.amazon.com/ec2/ for server instances

Make your Key Pair

  1. go to https://console.aws.amazon.com/ec2
  2. look at the E2C Dashboard on the left hand side
  3. scroll down to “NETWORK & SECURITY”
  4. click on “Key Pairs”
  5. it’s blank!
  6. click the big, blue button that says “Create Key Pair”
  7. give your key pair a name
  8. save the lovely file AWS gives you

 Create a Security Group

  1. go to https://console.aws.amazon.com/ec2
  2. look at the E2C Dashboard on the left hand side
  3. scroll down to “NETWORK & SECURITY”
  4. click on “Security Groups”
  5. it’s blank!
  6. click the big, blue button that says “Create Security Group”
  7. give your security group a name, description, and use the default VPC
  8. horray!


You’re Done. What Now?

Horray! You are set up! What to do now? If you have an application you have written, I suggest you serve it. If you are just playing along at home for fun, I recommend the e2c.forpoets.org tutorial using the Hello World app. Part of the tutorial is shown below:

Be sure you’re in the US East permalink

In the next step you will not be able to find my AMI unless you tell Amazon you’re in the US East region.

So, before proceeding, look in the upper-left corner of the console, click on the popup and choose US East (Virginia). Screen shot.

This will cause the new instance to be created on a server in Virginia.

Launch your server permalink

Now it’s time to create your virtual machine and launch it.

1. In the left margin of the dashboard, click on the AMIs link. You should see a popup menu in the upper left corner of the panel. Choose Public Images from the popup. It might take a few seconds for the list to appear (there are a lot of public images).

2. Type ec2ForPoets28 in the little search box near the top of the screen. A single item should show up in the list. Click on the checkbox next to its name.

3. Click the Launch button near the top of the screen.

4. A big dialog appears.

5. Set Number of Instances to 1 (it should be the default).

6. Change the Instance Type to Micro (t1.micro, 613 MB). Leave the Availability Zone choice on No Preference.

7. Click Continue to get to the next dialog. You can accept the defaults. Click Continue.

8. This is where you give your instance a name. It’s like naming a cat. Pick something fun and memorable. (I named mine Einstein.)

9. Click Continue to get to the next dialog, where you choose the Key Pair. Click the radio button next to Choose from your existing Key Pairs, and then choose the one you created earlier in the popup menu. (We called our example Tahoe.)

10. Click Continue to get to the next dialog. Click the radio button next to Choose one or more of your existing Security Groups, and then select the default Security Group.

11. The final dialog in the sequence appears, summarizing the choices you made. If everything looks okay, click the Launch button at the bottom of the dialog. Pause for a moment to consider your accomplishment. You are now a Cloud Computing Expert. 🙂

12. In the left margin of the dashboard, click Instances. You should see a single entry whose status is “starting.” We’re now waiting for it to change to “running.” This could take as much as 10 or 15 minutes, depending on how busy the angels and elves at Amazon are.


Later if you want to go “shopping” for other AMIs, Amazon maintains a directory that’s a bit like shopping for iPods or books, of popular AMIs. Too bad they don’t offer the same reviewing options as they do for consumer products. (Consider this a feature request.)

In putting together the sample server for this tutorial, I started with Amazon’s Basic Microsoft Windows Server 2003 AMI with none of the frills.

(go read the whole thing at ec2.forpoets.org)

Wake the server up permalink

Wait as much as 15 or 20 minutes for the status of the server in the Instances panel to change from “starting” to “running.” Now we just have to kick it in the butt to get the server software launched. You do that by logging in the first time.

1. First, locate the Key-Pair file (mine is called Tahoe), open it with a text editor (Notepad on Windows, TextEdit on the Mac). Select-All. Copy. Close the file.

2. In the left margin of the dashboard, click on the Instances link.

3. Right-click on the instance you just launched. A popup menu appears. From the menu, choose Get Windows Password.

4. A big dialog appears explaining what it means to decrypt your password. Click in the “Private Key” box and paste the text you copied in Step 1. Click the Decrypt Password button. It takes a few seconds, then…

5. A dialog appears with the server password. Leave it open so you can refer to it in the next steps. (If you know how, you might want to take a screen shot of this dialog.)

6a. Launch the Remote Desktop Connection app from the previous section. Copy the address of the computer to the clipboard (in my screen shot it’s ec2-72-44-33-187.compute-1.amazonaws.com). Paste it into the dialog that opens in the RDC app. Click on the wedge next to the word Options in the RDC window. Where it calls for the User name, enter Administrator. Then Copy the Decrypted Password from the dashboard, and paste it into the Password part of the RDC app. Click the big Connect button in the lower-right corner of the RDC window.

6b. If you’re using CoRD on a Mac, instead of Remote Desktop Connection, the process is slightly different. In the lower left corner of the app window you’ll see a wedge, the letter i and a big plus sign. Click on the plus sign. A dialog appears. Enter a name for the server, I like to name mine after football players or soft drinks, but you could just call it My First EC2 Server. Then enter the address as in step 6a. The username is Administrator, and the password comes from step 5. Click the Save password checkbox so you don’t have to enter the password every time you connect. Below that, you can determine the size of the display, and some very nice advanced options that you can worry about later (accept the defaults for now). Close the Inspector and double-click on the name of the server in the left margin of the big window.

7. If all goes well, you should see your server running in a window on your desktop. But don’t be fooled, this virtual computer exists in the cloud, not here or where you are. It’s somewhere “up there.”

A picture named poetsStartupWindowsSmall.gif

8. Three apps are visible: Firefox, the OPML Editor and the Windows Task Manager. OPML is, in addition to be an outliner, a web server. In the next section we’ll access this server in a web browser on your desktop machine. You can close the RDC window, or leave it open, if you want to explore. It’s just a Windows machine. 🙂

(go read the whole thing at ec2.forpoets.org)

Visit your server permalink

1. In the left margin of the dashboard, click on the Instances link.

2. Click on your instance. (There probably is just one in the list.)

3. Look in the lower portion of the window for a field named Public DNS. Copy it to the clipboard.

4. Open a web browser, paste into the address bar and press Return. You should see a sign-in screen that asks for a username and password. The username part is easy, it’s admin. The password is easy too. It’s the one you found in the previous section, from the adminPassword.txt file.

5. Once you enter the username and password you should see a screen that looks something like this.

The Hello World app permalink

At the beginning of the tutorial I promised you would see the Hello World app running on your new server.

1. Add “helloWorld” at the end of the URL in the previous example and press Return.

2. You should see Hello World, today’s date, the time, the IP address of the server, and a counter that starts at 0, and increments every time you refresh the page, which you should do a few times to prove that it’s a dynamic page.

I know it sounded more exciting a few minutes ago. Because now you’re a server dude or dudess, and this kind of stuff doesn’t impress us really.

(go read the whole thing at ec2.forpoets.org)

How to turn off the server permalink

As Amazon makes very clear, until you shut off the server, they’re going to charge $0.125 per hour. So if you’re done, here’s how to turn it off.

1. From the dashboard, click on Instances. You should see one item, the instance we just launched.

2. Click on the checkbox in the leftmost column.

3. Right-click it, and choose Stop from the popup menu. This causes the server to go to sleep, it’s as if you closed the lid on a Windows laptop. You can turn it back on by choosing Start from the same menu. Both these operations are quite quick, they take a few seconds each.

4. If you know you never want to run this instance again, choose Terminate from the popup menu. This shuts down the server, and throws away the instance permanently. It’s like taking your PC out to the garbage dump and driving away. 🙂

5. If you restart the instance, it will have a different address. When you access the server from your Remote Desktop client, you will have to change its configuration so that it knows about the new address.

Look to e2c.forpoets.org demo above or the bonzai demo for more info about setting up an AWS server.

Posted in Fiddling & Time Wasters, Technical Geekery, Tutorial, Web

Now Serving At The Rails Diner

New Instance

(Create a new instance of your Guest method.)

@guest  =  Guest.new

New Instance with Side of Association

(This associates this guest with their meal. Note the plural “meals“.)

@meal = @guest.meals.build

New Instance with Side of Association (no split plates)

(Despite the plural “meals”, each meal may belong to only one guest. No split plates! This will assign the id of @guest in the @meal’s guest_id column.)

@meal = @guest.build_meals


More on Active Record Associations: here. Thank yous to vihnboy and Duplex.

Posted in Rails && Sinatra && Camping, Ruby, Useful Code