Created
February 3, 2011 00:44
-
-
Save eqdw/808831 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def change_description(cl) | |
Kernel.const_get(cl.model).describe_change(cl) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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