Questions tagged [ancestry]

Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord model to be organised as a tree structure

https://github.com/stefankroes/ancestry

194 questions
2
votes
2 answers

Dynamic Select with ancestry

My application using ancestry gem. class Location < ActiveRecord::Base has_ancestry :cache_depth => true has_many :posts end class User < ActiveRecord::Base belongs_to :location end I created some random Location, Alaska California Los…
2
votes
1 answer

using ActiveModelSerializers and having children rendered with specific Seriazlier

I have the following relationships (using RoR 3.2.13 and ancestry 2.0.0) and REALLY need some help in configuring how the serializer renders with the MenuHeaderSerializer: class Menu < ActiveRecord::Base has_many :menu_headers end class…
timpone
  • 19,235
  • 36
  • 121
  • 211
2
votes
1 answer

Rails validate uniqueness on level

I have ancestry tree in my app. I want to implement uniqueness for records only on the same level. let me explain Records: #, #, #
Mykhailo Rybak
  • 163
  • 1
  • 2
  • 9
2
votes
1 answer

'method_missing': undefined local variable or method 'has_ancestry'

I am following this tutorial (http://www.tweetegy.com/2013/04/create-nested-comments-in-rails-using-ancestry-gem/) on how to setup the Ancestry gem for nested comments. When I run through the tutorial on a normal rails app it works fine. My issue…
2
votes
2 answers

FactoryGirl + Ancestry with two level deep

Basically: I have a Structure model that has many Subjects. Each subject has a parent and it can be 2-levels deep. A Structure has to have one Subject at_depth 0 and one Subject at_depth 2. The problem: I can't figure out how to build my…
Nima Izadi
  • 996
  • 6
  • 18
2
votes
1 answer

Ember.js model to be organised as a tree structure

I am learning Ember.js, using a Rails backend. I'm looking to set up a tree structure for relating a Group model to itself (Sub-Groups). Since it's pretty mature, I'd like to link up the Ancestry gem for consumption on the Ember side. Ancestry adds…
neon
  • 2,811
  • 6
  • 30
  • 44
2
votes
1 answer

How can I find the ultimate ancestor of an ActiveRecord entry where parent_id is optional?

I have a Rails 3.2 application where Product is a model. Product contains attributes identifier, which is never null, and parent_identifier, which may be null. The relationships, when they exist, can be chained through many generations. My challenge…
RubyRedGrapefruit
  • 12,066
  • 16
  • 92
  • 193
2
votes
1 answer

Order sub-tree navigation using ancestry gem

I'm following the rails cast Tree Based Navigation. I want to order the sub-tree alphabetically. In my PagesController I have @page_for_nav = Admin::Page.find_by_permalink!(params[:id]) which gets called by <%= render 'layouts/sub_navigation',…
Taylor Williams
  • 256
  • 4
  • 22
2
votes
1 answer

Rendering rails partials in helper methods

I'm a rails beginner and I'm having a bit of trouble understanding how the render method works. I'm following along with this railscasts, which has to do with the ancestry plugin for rails. The part I'm having trouble understanding is the…
android_student
  • 1,246
  • 1
  • 13
  • 32
2
votes
2 answers

How to render nested ul list for ancestry tree view

I want to render a structure shown below using content_tag where the collection is the ancestry object.
Achaius
  • 5,904
  • 21
  • 65
  • 122
2
votes
2 answers

Rails 3: Modeling groups and members as a hierarchy

A Group instance can contain Person instances or other Group instances. I want to use the Ancestry gem to mirror a hierarchy, but Ancestry does not seem to work with two different models. I don't want to use Single Table Inheritance on Person and…
RailinginDFW
  • 1,523
  • 12
  • 19
2
votes
2 answers

Ancestry - how to get all parent without children?

I am doing it this way: @disabled_options = [] Category.where('ancestry is NULL').each do |cat| @disabled_options << cat.id if cat.has_children? end Is there any more elegant way to get all parent without children?
user984621
  • 46,344
  • 73
  • 224
  • 412
1
vote
2 answers

Rails 'grouped_options_for_select' edit not working

My model Class Person belongs_to :job, class: "Job" end Class Job has_ancestry orphan_strategy: :adopt end in my view = form.select(:job_id, Job.all.map { |job| [job.name.titleize, job.id] }, {prompt: 'Job'}, {:class =>…
wiwit
  • 73
  • 1
  • 7
  • 26
1
vote
0 answers

Rails Ancestry can't get capital

I am using ancestry gem in rails 6 on my Location model. On the model, I have a location_type enum. class Location < ApplicationRecord enum location_type: ["continent", "country", "state", "state_capital", "country_and_state_capital", "city"…
Joe Bloggos
  • 889
  • 7
  • 24
1
vote
1 answer

Is something wrong with my ggplot2 or R code to plot an ordered ancestry stacked barplot?

I want to create an organized stacked barplot where bars with similar proportions appear together. I have a data frame of 10,000 individuals and each individual comes from three populations. Here is my data. library(MCMCpack) library(ggplot2) n =…
mdy
  • 43
  • 5
1 2
3
12 13