Created
September 10, 2008 17:13
-
-
Save brentd/9958 to your computer and use it in GitHub Desktop.
This file contains 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
# See ActionController::RequestForgeryProtection for details | |
# Uncomment the :secret if you're not using the cookie session store | |
protect_from_forgery # :secret => '76442f0e40a981d5e2b791b320bd8e94' | |
def must_be_admin | |
redirect_to '/' unless self.current_user.in_role?("admin") | |
flash[:notice_error] = "Access Denied..." unless self.current_user.in_role?("admin") | |
end | |
def set_changes_audit(entity_obj, old_record, new_record_ids, entity) | |
name_entity = entity_obj.class.to_s.downcase.pluralize | |
new_record = entity_obj.class.find(new_record_ids) if new_record_ids | |
if old_record && new_record | |
del_record = old_record - new_record | |
action_to_record("delete", del_record, name_entity, entity) | |
elsif old_record && new_record.nil? | |
action_to_record("delete", old_record, name_entity, entity) | |
end | |
if old_record && new_record | |
add_record = new_record - old_record | |
action_to_record("add", add_record, name_entity, entity) | |
end | |
end | |
def action_to_r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment