Module: HasHierarchy::Path::ClassMethods
- Defined in:
- lib/has_hierarchy/path.rb
Instance Method Summary collapse
Instance Method Details
#find_by_path(path) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/has_hierarchy/path.rb', line 10 def find_by_path(path) sep = path_separator parts = path.gsub(/\#{sep}*$/, '').split(sep) part = parts.pop path = parts.length > 0 ? parts.join(sep) + sep : '' where(path_part_column => part, path_column => path).first end |
#find_by_path!(path) ⇒ Object
19 20 21 |
# File 'lib/has_hierarchy/path.rb', line 19 def find_by_path!(path) find_by_path(path) or raise ActiveRecord::RecordNotFound end |