Mark Richman provides expert advice, strategy, and software solutions to businesses worldwide. His clients range from the Fortune 500 to small businesses to startups seeking dramatic results. Mark creates and improves business-critical web applications, increasing productivity and maximizing profits.

Archive for the ‘rails’ Category

Rails Integration Test with shoulda, factory_girl, webrat, and authlogic

I had some issues trying to use a symbol
session[:user_credentials_id]
vs. a string
session["user_credentials_id"]
Here is my solution:

require ‘test_helper’

class LoginTest < ActionController::IntegrationTest
context ‘A user’ do
setup do
@user = Factory(:user)
# puts @user.inspect
end

should ‘be able [...]

Tools of the Trade

Many of my colleagues in the Ruby on Rails community have been posting a “tools of the trade” blog post, covering their hardware and software preferences. Now that I am nearly Microsoft-free, I figured I’d update my list.
Hardware

Apple Mac Pro 8-core Xeon, 10GB RAM, 320GB + 500GB 7200rpm SATA drives. This is my main box [...]

How to install pg (postgresql) gem on Snow Leopard, 64 bit

This one was a toughy. I installed PostgreSQL 8.4 from source in /usr/local/pgsql. Install the gem as follows:
sudo -s
export PATH=/usr/local/pgsql/bin:${PATH}
env ARCHFLAGS=”-arch x86_64″ gem install pg

Seeding User and Role Data with seed-fu

Seed-fu is advanced seed data handling for Rails, combining the best practices of several methods together.
Here’s how to use seed-fu with users and roles (I use Authlogic and acl9):

Rails 2.3 Application Template template.rb

Here’s my current Rails 2.3 application template which uses the following features:

asset_packager
exception_notifier
paperclip
restful-authentication (generates user and session)
role-requirement (generates roles for user)
rspec
cucumber
active_merchant
sqlite3-ruby
will_paginate
haml
nifty_layout
Capistrano capify
database session store