Comments (4)
Just discovered the unscoped method and I've worked out a solution to the issue, but please let me know if I am missing something about the functionality of ancestry or if there is a better way of doing it.
Again, thanks for developing this library, it's solid.
- Nick
from ancestry.
Please investigate any incompatibilities with friendly id and describe them in detail. Where possible, please also suggest changes to resolve any issues. I really don't have time to do that myself.
Friendly id is an important gem and I would be glad to make any specific changes to resolve any incompatibilities between it and ancestry.
Additionally, you might approach rolftimmermans. He has commit access and might be willing to investigate the problem.
from ancestry.
@stefankroes I'm running into the same issue with ancestry 2.1.0 , Rails 4.2.4 with a Postgres DB.
Can you please re-open this issue, or comment what might be causing this?
class Node < ActiveRecord::Base
has_ancestry(:orphan_strategy => :adopt)
# has a name and a slug string attribute, the slug is supposed the be the path's names concatenated
after_save :generate_slug
#
def generate_slug
puts "OBJECT: #{self.name} ; PATH IS: #{self.path.pluck(:name).inspect}"
self.update_column(:slug , self.path.each_with_object([]) {|x,a| a << x.name}.join('/') )
end
end
Objects are created in this fashion:
root = Node.create(:name => 'root')
child1 = root.children.create(:name => 'child1')
OBJECT: child1 ; PATH IS: ["child1"]
child1.slug
=> 'child1' # oops!
child1.save
OBJECT: child1 ; PATH IS: ["root","child1"]
child1.slug
=> 'root/child1'
self.ancestors
does not appear to be set/valid during the execution of the after_save hook.
Looks like this might be an issue with multiple callbacks being registered.
from ancestry.
I really didn't like the way the ids were being updated before. Hoping the newer code will work much better for everyone
from ancestry.
Related Issues (20)
- anyone could give clarity to the readme? HOT 6
- Multiple root nodes HOT 1
- gui or gem for generic tree editing? HOT 3
- Make it easier to change the serialization format for the ancestry column HOT 11
- Do I still need to write an arrange_as_array routine to get a children inclusive ordered list? HOT 6
- release next version HOT 6
- having trouble displaying tree in select across different models/controllers
- How do i create a nested ancestry drop down collection_select list for rails forms? HOT 1
- [Idea] Remove InstanceMethods mixin HOT 4
- arrange_as_array causing unknown error HOT 7
- no definition for arrange in arrange_as_array HOT 5
- Falseful changelog, incorrect README and broken code in 4.3.0 HOT 23
- ancestor_ids_in_database removed? HOT 2
- Error in MaterializedPath2 descendants SQL? HOT 6
- Configuring Ancestry to use UUID keys HOT 4
- path_ids_in_database removed? HOT 5
- virtual depth_cache HOT 4
- Why is there no leafs method? HOT 1
- STI breaks arrange scoping HOT 3
- add support for virtual parent_id and root_id
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ancestry.