Skip to content

Instantly share code, notes, and snippets.

# My pretty prompt:
# - Truncates the first few dirs in long paths
# - red/green prompt based on return value of previous command
# - inserts git branch name if in a repo
# Developed primarily for debian/ubunu systems
# First, some stuff from the Ubunutu .bashrc
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then

This is a new version file /usr/bin/rails generated on my system by installing the Rails 3 Gem. The problem with this executable is that the ‘rails’ command no longer provided a way to execute the executables from Rails 2, because the bin had moved from Rails to Railties. A few more details in the related blog post.

Call a version of Rails 2 like so (after putting the following code in /usr/bin/rails):

rails _2.3.5_ myapp

The second file can be put in /usr/bin/rails2 as a convenience path to run the latest available Rails 2 version easily.

I’m working on both learning authlogic and Rails 3. The process here works (given the Rails 3.0.0.beta1 gem) for me. There is a list of the many resources I complied this from at the bottom of the document.

Travelers beware: this is incomplete, and possibly even wrong. But between the stuff about scaffolding and binary logic’s example app you should be able to get off your feet.

Basic Application

We assume Rails 3 is installed. We will create a rails app as usual.

rails authtest
cd authest
rails g scaffold post title:string body:text
rails g scaffold user username:string fullname:string is_admin:boolean
#!/usr/bin/bash
# Uninstall all the gems installed to your home directory, unless of course they have a dash in the name.
(echo "uninstall --install-dir=~/.gem/ruby/1.8";(ls ~/.gem/ruby/1.8/gems | grep -v rack | sed 's/\-[^ ]*//g')) | xargs gem
class ProductionsController < ApplicationController
#...
# GET /productions/1
# GET /productions/1.xml
# Alternately, old URLs:
# GET /productions/2009/11/23/Hyphenated-Title
def show
# Identify production if we got here by /month/day/year/slug URL,
# e.g. links generated for the old RPI TV website.
class ApplicationController < ActionController::Base
# ...
########################
# URL REDIRECTS #
########################
# Use this method to make sure that each page can only be accessed
# by one URI. Will return false if a redirect has occured.
# Example (in controller)