Guest User

Untitled

a guest
Jul 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. # lib/active_record_ext.rb
  2.  
  3. module ActiveRecordExtensions
  4. def self.included(base)
  5. base.extend(ClassMethods)
  6. end
  7.  
  8. # attempts to create an 'html-friendly' id
  9. def to_html_param(include_class_name = true)
  10. if include_class_name
  11. "#{self.class.name.parameterize.underscore}_#{self.to_s.parameterize.underscore}"
  12. else
  13. self.to_s.parameterize.underscore
  14. end
  15. end
  16.  
  17. module ClassMethods
  18. # nothing, at the moment
  19. end
  20. end
  21.  
  22. ActiveRecord::Base.send(:include, ActiveRecordExtensions)
Add Comment
Please, Sign In to add comment