The Business of Rails: Insurance

22 May 2007

In response to my post about being a Ruby on Rails consultant, a few seemed interested in my writing more about the business side of being a freelance developer, so this post is the first in a series on the topic. The first thing I decided to write about is business insurance, since it doesn’t seem to be discussed a whole lot in blog posts of this sort.

I was introduced to the world of business insurance by a kind client who suggested I really ought to look into it. It was something that I figured I would get to eventually, but wasn’t in a rush to do. After doing a bit of research, though, and getting some insurance for my LLC, I now recommend to anyone that will listen to get business insurance sooner rather than later. If you are looking into getting some insurance for yourself, the first thing you need to know is that there are, in fact, two types of insurance you should investigate.

Read the rest of this entry »


100 Days of Rails Consulting

9 May 2007

Today marks 100 days since I started doing freelance Ruby on Rails development, consulting, and training here in sunny Seattle, WA on a full-time basis. I must say, it’s been a blast.

Previous to the full-time consulting work, I was employed at a startup doing Rails for my day job. I worked on some cool stuff, worked with some cool people, and had a great time. Of course, all good things must come to an end, and when the funding stopped, so did my paycheck. Fortunately for me, I had been doing some freelancing on the side, so when the kick in the pants came, I was able to move quickly into freelancing full-time.

I have learned quite a bit in the past 100 days… about running a business, working with clients, and managing stress. A year ago I never would have thought I would enjoy this, but I’ve discovered that I really do. I’m still working on some cool stuff, with some cool people, and every day is an adventure.

So, if you need a web application built, or if you need some guidance on building one, or if you’d like some one-on-one Rails training, drop me a line. If you’re thinking of diving in to freelancing full time and have a question you’d like to ask, send it my way and I’ll do my best to impart lessons learned the hard way. :)



Ruby on Rails Trainer/Consultant

13 Apr 2007

I just finished an IM training session with a client and realized I hadn’t mentioned on my blog that I’m doing that sort of thing these days. So, here’s a little invitation to you if you are looking for some personalized Ruby on Rails help, or some one-on-one Rails training.

Contact me and I’ll be happy to help you on an hourly basis via IM and email, or on a daily basis at your location. If you like the excellent advice Jamis and Michael provide at The Rails Way, you’ll love the results you can get for your project with some personal attention from me.

Whether you are looking for an answer to a particular question, some tips on a sticking point in your application, or more general training on Rails idioms and best practices, I can help you accelerate your journey towards Rails mastery. The clients I have worked with feel they have really benefited from having some expert guidance as they build their applications, and I enjoy helping others learn new things, so it’s a fun time for everyone involved. :)

Don’t delay! An operator (me) is standing by! Act now to get Rails training!



Designer needed

29 Mar 2007

This may come a surprise to you, but I’m terrible at design. So I ask you, the excellent and friendly community at large, for your assistance. I need some design help. I’m talking the whole enchilada, here: user interface / user experience, branding, etc. I need every aspect of design under the sun to help me launch CatchTheBest. So, if you have the skills, the time, and the interest, or you know someone who does, please get in touch.

Update:
Since I didn’t specify this originally, and since people have asked, yes, I am willing to pay for this work. I know good work isn’t free. :) Of course, since this is a bootstrap situation, I don’t have a huge budget, but I am fairly flexible on the timeframe.



Rails, OpenID, and Acts as Authenticated

5 Mar 2007

This weekend I added OpenID to a Rails application for the first time, and this blog post describes the steps I took to integrate OpenID with Acts as Authenticated for account creation and access.

First I installed David’s OpenID Rails plugin (as discussed at David’s blog) into my application which was already using AAA to handle account creations and logins. I then created the following migration to add the OpenID identity URL to my user model:

class AddOpenId < ActiveRecord::Migration
  def self.up
    add_column :users, :identity_url, :string
  end

  def self.down
    remove_column :users, :identity_url
  end
end

And I changed the User model to allow accounts to be created either with login/email/password or with only an identity url (only changed lines are listed):

class User < ActiveRecord::Base
  validates_presence_of :login,
    :email, :if => :not_openid?
  validates_length_of :login,
    :within => 3..40, :if => :not_openid?
  validates_length_of :email,
    :within => 3..100, :if => :not_openid?
  validates_uniqueness_of :login, :email, :salt, :allow_nil => true

  def password_required?
    not_openid? && (crypted_password.blank? or not password.blank?)
  end
 
  def not_openid?
    identity_url.blank?
  end
end

This allows me to create User records without the usual required fields as long as the user created the account via an OpenID login.

And finally, the controller changes:

class AccountController < ApplicationController
  def login
    if using_open_id?
      open_id_authentication
    elsif params[:login]
      password_authentication(params[:login], params[:password])
    end
  end

  protected
 
    def password_authentication(login, password)
      if self.current_user = User.authenticate(params[:login], params[:password])
        successful_login
      else
        failed_login("Invalid login or password")
      end
    end
 
    def open_id_authentication
      authenticate_with_open_id do |result, identity_url|
        if result.successful?
          if self.current_user = User.find_or_create_by_identity_url(identity_url)
            successful_login
          else
            failed_login "Sorry, no user by that identity URL exists (#{identity_url})"
          end
        else
          failed_login result.message
        end
      end
    end

  private
 
    def successful_login
      redirect_back_or_default(index_url)
      flash[:notice] = "Logged in successfully"
    end

    def failed_login(message)
      redirect_to(:action => ‘login’)
      flash[:warning] = message
    end
end

That’s it! You can see it in action at the Rails plugin directory.

Update
I updated this code to match the plugin changes that were made between the time I installed the plugin and the time I posted this entry. :)

Update 2
I made another change to the code based on Geoff’s comment. Thanks, Geoff!