Sha256: e4c650ea9893b4da48b4f2fe49fdea441c4f1f512720dae5af946a5e5bddc1a2
Contents?: true
Size: 408 Bytes
Versions: 5
Compression:
Stored size: 408 Bytes
Contents
Category.class_eval do def self.create_chain( aChain, # an array of names from leaf to root aCatType # an object or id of CategoryRoot ) aCatType = CategoryType.find_by_id(aCatType) if aCatType.is_a? Fixnum parent = nil aChain.each do |name| currCat = Category.find_by_name(name) || aCatType.categories.create!(:name => name,:parent => parent) parent = currCat end parent end end
Version data entries
5 entries across 5 versions & 1 rubygems