Initialization of inverted models

Given the following situation:

client belongs_to entity

entity has_one client
entity has_one vendor
entity has_many contacts
entity has_many sites
etc.

Creating a new client should test if an entity with the existing name is
already on file and return it if so, else the process should create a
new entity with identically named attributes in entity passed the
initial values from client.
I think that this sort of complexity belongs in the client model but I
am open to arguments as to where else it might go.

Is there a recommended Rails approach that deals with this situation?
Should I do all this creating and initializing in a before_create
specified method?

James Byrne wrote:

Given the following situation:

client belongs_to entity

entity has_one client
entity has_one vendor
entity has_many contacts
entity has_many sites
etc.

class SomeController < ApplicationController
  def find_or_create_client
    # Don't use find :first as it will throw
    found = Entity.find(:all, :conditions => ['matching_field = ?',
params[:entity][:matching_field]])
    if found.blank?
      # Please refer to rails casts on how to do creates through
associations
      # I think it's complex forms part 1, 2, and 3
      @client = Entity.create(params[:entity]).client
    else
      @client = found.first.entity.client
    end
  end
end

hth

ilan