I'm using ActiveRecord in a ruby project without rails. I need to define composite primary key for a table.Normally migration creates primary key automatically. Is it possible to define my own composite primary key for a table using active record?
            Asked
            
        
        
            Active
            
        
            Viewed 8,914 times
        
    10
            
            
        - 
                    6Why mark a question as duplicate if the original question doesn't have an answer? I just wasted my time looking the other question, in the other hand this question has two answers. I understand that the duplication is correct, but the mark confuses more than it helps. – Sertage Jul 01 '15 at 12:10
2 Answers
7
            There are some gems that give you this ability, such as composite_primary_key.
I don't know if Rails 4 has added support for this, would be very interested to hear if it does.
 
    
    
        Matt
        
- 13,948
- 6
- 44
- 68
1
            
            
        Question has been asked before, checkout: How to set composite key in Rails application
http://compositekeys.rubyforge.org/ might also be useful.
 
    
    
        Community
        
- 1
- 1
 
    
    
        MatthewFord
        
- 2,918
- 2
- 21
- 32
