views:

18

answers:

1

Quick question:

If I have a one-to-many relationship, such as this:

class SalesPerson < ActiveRecord::Base
  has_many :deals
end

class Deal < ActiveRecord::Base
  belongs_to :sales_person
end

how can I delete a Sales Person, without negatively impacting the deals associated with them? The use-case for this would be if someone left the organization. We still need a record of the deals in the database, but that sales person record is no longer needed.

Would it just be better to have an active/inactive flag on the sales person instead?

Thanks.

A: 

For this kind of situations I've use acts_as_paranoid, basically It adds a new timestamps column: deleted_at and overrides some of your AR finders.

jpemberthy