Comments (6)
This is not possible right now and would require a lot of changes. Can you provide a use case?
from ancestry.
I guess the one that springs to mind is if you aren't using Rails' id field as you primary key, maybe you are using a permalink or some other kind of string, e.g a hash.
from ancestry.
You should always use the ID column as you primary key in Rails. If you also want to save permalink slugs that's just fine! Just use something like this to build the path:
def permalink; path.map(&:slug).join('/'); end
You should not use the content of the ancestry column directly.
from ancestry.
I would agree that in most circumstances its wise to use the ID column as your primary key, but sometimes there are good reasons for not using it, for example if you have a natural unique key (e.g ISBN number, Invoice Number, MAC address) or your using a GUID to aid data migration/sync between distributed systems.
from ancestry.
Even in those cases; please still just use an id column as well. What if we run out of ISBN numbers and the scheme changes or we start reusing them? What if your application that uses ISBN numbers needs to be extended to track unpublished books?
Also database are more efficient at looking up records with integer id columns; ISBN numbers, invoice numbers and mac addresses all contain special characters (:-/) which requires you to save them as a string. Same goes for generating ids and integrity contraints like uniqueness and foreign keys.
There is really no reason to just have both: an internal id and an external id like a isbn, mac address etc.
from ancestry.
I think natural versus artificial keys is a moot point. The choice is dependent on your data and stance on such things, there is no right/wrong. Because the Rails way is to have a artificial key for everything I understand this is an edge case, 99% of people will be happy with using the id, in fact more than likely that's all they'll have.
But it is perfectly valid to not want to use an artificial key. Merging data is hellish with auto-inc id's since they are not unique like UUID's, again not something 99% of Rails developers need to worry about.
from ancestry.
Related Issues (20)
- Design and buid FTW Newsletter Landing Page
- 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
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.