Skip to content

Instantly share code, notes, and snippets.

@eqdw
Created February 3, 2011 00:44
Show Gist options
  • Save eqdw/808831 to your computer and use it in GitHub Desktop.
Save eqdw/808831 to your computer and use it in GitHub Desktop.
def change_description(cl)
Kernel.const_get(cl.model).describe_change(cl)
end
def change_description(cl)
if cl.event == "CREATE"
desc = "Created #{cl.model.titleize}"
if cl.model == "Activity"
desc += " in Register \"#{h cl.register.name}\""
if(cl.register.specific?)
fac = cl.register.facilities.first
if fac.name.blank?
desc += " in Facility \"No Name\""
else
desc += " in Facility \"#{h cl.register.facilities.first.name}\""
end
elsif cl.register.shared?
desc += " (Shared)"
end
end
elsif cl.event == "UPDATE"
if cl.model =~ /Activity/
# desc = "Modified Activity in Register \"#{h cl.register.name}\""
desc = "Activity \"#{h cl.activity.name}\", changed #{cl.field} from \"#{h cl.old_value}\" to \"#{h cl.new_value}\""
else
desc = "Changed #{cl.field} from \"#{h cl.old_value}\" to \"#{h cl.new_value}\""
end
end
return desc
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment