Skip to content

Instantly share code, notes, and snippets.

@bogdan
Created October 15, 2010 10:25
Show Gist options
  • Save bogdan/627969 to your computer and use it in GitHub Desktop.
Save bogdan/627969 to your computer and use it in GitHub Desktop.
class CompanyObserver < ActiveRecord::Observer
observe Company
def after_create(company)
unless company.current_issue
Issue.create!(
:title => "Создана компания #{company.title}",
:source => company
)
end
end
def after_update(company)
unless company.blocked?
Issue.create!(
:title => "Изменена компания #{company.title}",
:source => company
)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment