Guest User

Untitled

a guest
Feb 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1.  
  2.  
  3. # See ActionController::RequestForgeryProtection for details
  4. # Uncomment the :secret if you're not using the cookie session store
  5. protect_from_forgery # :secret => '76442f0e40a981d5e2b791b320bd8e94'
  6.  
  7. def must_be_admin
  8. redirect_to '/' unless self.current_user.in_role?("admin")
  9. flash[:notice_error] = "Access Denied..." unless self.current_user.in_role?("admin")
  10. end
  11.  
  12. def set_changes_audit(entity_obj, old_record, new_record_ids, entity)
  13. name_entity = entity_obj.class.to_s.downcase.pluralize
  14. new_record = entity_obj.class.find(new_record_ids) if new_record_ids
  15.  
  16. if old_record && new_record
  17. del_record = old_record - new_record
  18. action_to_record("delete", del_record, name_entity, entity)
  19. elsif old_record && new_record.nil?
  20. action_to_record("delete", old_record, name_entity, entity)
  21. end
  22.  
  23. if old_record && new_record
  24. add_record = new_record - old_record
  25. action_to_record("add", add_record, name_entity, entity)
  26. end
  27.  
  28. end
  29.  
  30. def action_to_r
Add Comment
Please, Sign In to add comment