#skipping standard ugly scaffold controller paste#Project modelclass Project < ActiveRecord::Base #belongs_to :client, :foreign_key => "client_id", :class_name => "Client" #has_many :programs, :foreign_key => "program_id", :class_name => "Project", :dependent => :destroy # no need to specify default values belongs_to :client has_many :programs, :dependent => :destroy validates_presence_of :client_id, :name validates_associated :clientend#Client modelclass Client < ActiveRecord::Base # same has_many :projects, :dependent => :destroy validates_presence_of :name def validate # exists? is a class method, naturally but the bigger issue here is that this validation will mean no new records can be created. #if self.exists?(self.id) # return true #end #return false # nobody uses 'return' in ruby and self is the default recipient. Anyway, see above. Client.exists?(id) endend