masciugo / genealogy Goto Github PK
View Code? Open in Web Editor NEWMake ActiveRecord model act as a pedigree
License: MIT License
Make ActiveRecord model act as a pedigree
License: MIT License
I am trying to use add_siblings(*siblings)
method to add more then one sibling at a time. I am giving array of users and I am getting above error.
user.add_siblings([user1, user2,..])
Whereas If I pass objects comma separated its working fine.
user.add_siblings(user1, user2,..)
As per API document it should work.
For more details Please check the below stacktrace.
["/home/mukesh/.rvm/gems/ruby-2.5.1@go-server/gems/genealogy-2.5.1/lib/genealogy/util_methods.rb:175:in
check_indiv'", "/home/mukesh/.rvm/gems/ruby-2.5.1@go-server/gems/genealogy-2.5.1/lib/genealogy/util_methods.rb:162:in block in check_incompatible_relationship'", "/home/mukesh/.rvm/gems/ruby-2.5.1@go-server/gems/genealogy-2.5.1/lib/genealogy/util_methods.rb:159:in
each'", "/home/mukesh/.rvm/gems/ruby-2.5.1@go-server/gems/genealogy-2.5.1/lib/genealogy/util_methods.rb:159:in check_incompatible_relationship'", "/home/mukesh/.rvm/gems/ruby-2.5.1@go-server/gems/genealogy-2.5.1/lib/genealogy/alter_methods.rb:184:in
add_siblings'", "/home/mukesh/.rvm/gems/ruby-2.5.1@go-server/gems/genealogy-2.5.1/lib/genealogy/alter_methods.rb:211:in `add_sibling'",
`
Hi,
I am the fan of genealogy. It saved a lot of my valuable time. I have used 1.5.0 till now. My Application was worked very well when i was in 1.5.0 version.
After updating to gem to latest version ( 2.0.2 ), i am not able to adding a child to user. It is throwing an exception called "User1 Can't be father of User2".
Please resolve the issue and let me know.
Thank you!
I'm getting: undefined method `arity' for {:class_name=>"Person", :optional=>true, :foreign_key=>"father_id"}:Hash
I'm using Ruby 3.0.0 and Rails 6.1.1. Followed all the install steps and added indexes, still crashing with said message. The entry point for the error is has_parents
on person.rb
.
Any ideas?
The query for siblings @member.siblings(half: :include)
fails due to an invalid query:
ERROR: operator does not exist: integer == integer
Seems that Postgres (and probably other SQL languages) do not support the double equals operator. Found at line 104 of query_methods.rb.
Would you be so kind to point me in the right direction to create an index of users in a family tree format?
Hi, thanks for the great gem.
Having upgraded to rails 5.1, I'm getting the following depreciation warning:
Passing a class to the class_name
is deprecated and will raise an ArgumentError in Rails 5.2. It eagerloads more classes than necessary and potentially creates circular dependencies. Please pass the class name as a string: `belongs_to :father
Should be an easy fix by passing self.class_name instead of self in the belongs_to and has_many relationships?
Thanks!
Hi,
Great gem, no problems so far with it, but seem to have now hit a limitation which is setting up a spouse, or multiple without children. Had a look at the master code and doesnt look like this is supported, do you have any thoughts on this?
I was thinking about a join table, which could keep some additional metadata with it, like status of relationship, eg divorced, and others like wedding date, or anything else that makes sense.
In my app, i'll either just implement a hidden child, or a join table, but if you've got any idea of direction yourself, i could help out.
thanks,
Stewart.
Hi @masciugo,
I have the fixed the previous my issues my own. They are working :)
I wanted to support the use case where I can have gender as Unknown - U as value.
Is it possible ? I am trying to do so but getting many things to change. Still facing issues. This is kind of very important for me to solve at this stage.
Can you please help and let me know the possibility.
Thanks,
Mukesh
How to check if the User is already in the list of sibling ?
It fails during siblings assignment when there is already User in DB as sibling. Either this case to be handled or we can give a method to check user if he has added sibling already.
Please let me know if you want more details.
Great gem, it works with active record.
Is there a way I can use mongoid? thx
Currently spouses
method is just checking if there is any children with the spouse or not. In case no children then its omitting the spouse.
Say for eg.
User has added current spouse but has no children yet. When he checks spouses method it returns no result. If user checks using current_spouse
method then it shows a result.
I believe we should consider current_spouse
as well for spouses.
Ref: https://github.com/masciugo/genealogy/blob/master/lib/genealogy/query_methods.rb#L63
Hi there!
Thanks for this gem. I'm a bit confused how to best add indexes to my project though. Specifically how to do the "in combination" part. You say:
Add indexes, separately and in combination, to parents columns
And I have this so far:
class AddIndexToPeople < ActiveRecord::Migration
def change
add_index :people, :father_id
add_index :people, :mother_id
add_index :people, :current_spouse_id
add_index :people, [:father_id, :mother_id]
end
end
I'm not sure about that last one though. Can you help fill in the missing blanks for me? Thanks!
I'm trying to do something like the code shown below but rails returns undefined method name for nil
% if @person.parents %>
<% if @person.mother %>
Mother:
<%= @person.mother.name %>
<% if @person.father %>
<p>
<strong>Father:</strong>
<%= @person.father.name %>
</p>
<% end %>
<% end %>
Hey, thank you for this gem, really helpful for my project.
There is a small mistake in the error message raised by the current_spouse option defined in the private method raise_unless_current_spouse_enabled
. The message should be
Spouse tracking not enabled. Enable it with option 'current_spouse: true' for has_parents method}
instead of
Spouse tracking not enabled. Enable it with option 'current_spouse_enabled: true' for has_parents method}
Cheers
Hello,
I get this error when running bundle exec rake
:
genealogy[master]: bundle exec rake
/Users/aurels/.rbenv/versions/1.9.3-p448/bin/ruby -I/Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib:/Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-support-3.0.3/lib -S /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/exe/rspec ./spec/genealogy/alter_current_spouse_spec.rb ./spec/genealogy/alter_grandparents_spec.rb ./spec/genealogy/alter_offspring_spec.rb ./spec/genealogy/alter_parents_spec.rb ./spec/genealogy/alter_siblings_spec.rb ./spec/genealogy/model_lifecycle_spec.rb ./spec/genealogy/model_settings_spec.rb ./spec/genealogy/query_methods_spec.rb --format documentation --color
/Users/aurels/Dev/genealogy/spec/genealogy/alter_current_spouse_spec.rb:23:in `block (4 levels) in <module:AlterCurrentSpouseSpec>': undefined method `its' for #<Class:0x007fc954f27428> (NoMethodError)
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/aurels/Dev/genealogy/spec/genealogy/alter_current_spouse_spec.rb:21:in `block (3 levels) in <module:AlterCurrentSpouseSpec>'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/aurels/Dev/genealogy/spec/genealogy/alter_current_spouse_spec.rb:19:in `block (2 levels) in <module:AlterCurrentSpouseSpec>'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/aurels/Dev/genealogy/spec/genealogy/alter_current_spouse_spec.rb:16:in `block in <module:AlterCurrentSpouseSpec>'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `module_exec'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:331:in `subclass'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/example_group.rb:227:in `block in define_example_group_method'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/dsl.rb:41:in `block in expose_example_group_alias'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/dsl.rb:79:in `block (2 levels) in expose_example_group_alias_globally'
from /Users/aurels/Dev/genealogy/spec/genealogy/alter_current_spouse_spec.rb:6:in `<module:AlterCurrentSpouseSpec>'
from /Users/aurels/Dev/genealogy/spec/genealogy/alter_current_spouse_spec.rb:3:in `<top (required)>'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in `load'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in `block in load_spec_files'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in `each'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/configuration.rb:1057:in `load_spec_files'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:97:in `setup'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:85:in `run'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:70:in `run'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib/rspec/core/runner.rb:38:in `invoke'
from /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/exe/rspec:4:in `<main>'
/Users/aurels/.rbenv/versions/1.9.3-p448/bin/ruby -I/Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/lib:/Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-support-3.0.3/lib -S /Users/aurels/.rbenv/versions/1.9.3-p448/lib/ruby/gems/1.9.1/gems/rspec-core-3.0.3/exe/rspec ./spec/genealogy/alter_current_spouse_spec.rb ./spec/genealogy/alter_grandparents_spec.rb ./spec/genealogy/alter_offspring_spec.rb ./spec/genealogy/alter_parents_spec.rb ./spec/genealogy/alter_siblings_spec.rb ./spec/genealogy/model_lifecycle_spec.rb ./spec/genealogy/model_settings_spec.rb ./spec/genealogy/query_methods_spec.rb --format documentation --color failed
Any idea why ?
Best,
Aurels
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.