Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Matthew Brown
    @matthewbga
    gitter*
    Rishav Paul
    @rpaul93
    Hi, how can I order siblings in ancestry?
    Brandon Lawrence
    @Brantron
    whats the syntax for adding an ancester to an object on creation?
    I tried Product.create(:name => 'Cheap Koozies', :parent => 'Drinkware') but it didn't work. The Drinkware object already exists
    nchafai
    @nchafai

    @jimmybaker In rails 2, i do this :
    grand_parent:
    name: Grand parent

    parent:
    name: Parent
    ancestry: '<%= Fixtures.identify(:grand_parent) %>'

    child:
    ancestry: '<%= Fixtures.identify(:grand_parent) %>/<%= Fixtures.identify(:parent) %>'

    Kyle Tully
    @kyletully
    Hi All,
    Am using Ancestry inside a mountable engine on rails 4.2.2 and receive the following error "undefined local variable or method `has_ancestry' when adding "has_ancestry" to the model.rb file
    Is there anything different needed when installing Ancestry within a mountable engine?
    Oleksandr Bratashov
    @abratashov

    Hello guys, could you help me with some question, when i setup ancestry for my model Category and create 4 items wich includes each other, last item has depth 2, but it shuld be 4 http://prntscr.com/br8hww

    A - 1
    B - 2
    C - 2 (should be 3)
    D - 2 (should be 4)

    Denny Mueller
    @dennym
    Hey anyone available for a second?
    Jason Frey
    @Fryguy
    what's up @dennym ?
    Tim Wisniewski
    @timwis
    Hi all šŸ‘‹ Iā€™d like to leverage recursive window queries (aka common table expressions, a modern feature of Postgres and MySQL) for my nesting/ancestry, to optimise query performance. Has anyone heard of a way to do that in rails?
    Jason Frey
    @Fryguy
    @timwis I haven't seen anything gemwise, personally, but there is this: https://sonnym.github.io/2017/06/05/common-table-expressions-in-activerecord-a-case-study-of-quantiles/
    and this - rails/rails#37944
    Tim Wisniewski
    @timwis
    @Fryguy thanks, I came across those as well. Given how complex those Arel bits look, it seems like a great candidate for a module :/
    Wish I knew enough about rails modules to build it myself šŸ¤”
    Tim Wisniewski
    @timwis
    Oh my gosh, I just realised that ancestry uses the same exact approach that I've been using in my app for 6 years! That means I can potentialy migrate to it without actually changing my database :O Only difference is my paths look like /1/3/5/ (with leading and trailing slashes)
    Julio Papel
    @JulioPapel
    Hi guys, I added ancestry to my Category Model and it works nicely on the console, but to show a pull_down menu and update the parent of that category. I'm doing something like this: = fae_pulldown f, :parent, size: 'short', collection: Category.roots.order(:name) but it can't find the parent. if I use :ancestry it shows the form but cant submit! Any Ideas?
    Eric Pugh
    @epugh
    So... Any one have a recommendation for a front end tool for displaying a has_ancestry graph? Hoping to not start at the basics with D3 ;-)
    Eric Pugh
    @epugh
    how do I associate two existing objects togetehr? try_one.children << try_two was my first guess!
      try_two.parent = try_one
      try_two.save!
    
      assert_equal try_one.children.first, try_two
    Eric Pugh
    @epugh
    anyone done anything with DOT language and this gem?
    Jason Frey
    @Fryguy
    If you don't mind querying the whole thing up front, you can print it rather easily be using subtree.arrange, then walking it...
    def print_objs(subtree, indent = '')
      subtree = subtree.sort_by { |rec, _children| rec.name }
      subtree.each do |rec, children|
        puts "#{indent}- #{rec.name} (#{rec.id})"
        print_objs(children, "  #{indent}")
      end
    end
    
    roots = Model.roots.sort_by(&:name)
    roots.each do |root|
      print_objs(root.subtree.arrange)
      puts("\n")
    end
    Keenan Brock
    @kbrock
    thanks jason. that looks slick