What is the "key" attribute keyword for in rails?
In diaspora, there is a class that includes the code below, however I can't find any documentation on what the "key" keyword is or how it is used. Any help? Thanks!
Person.rb
class Person
#omitted for clarity
key :url, String
key :diaspora_handle, String, :unique => true
key :serialized_key, String #Public/private key pair for encryption.
key :owner_id, ObjectId #Extraordinarily security sensitive because...
one :profile, :class_name => 'Profile'
many :albums, :class_name => 'Album', :foreign_key => :person_id
belongs_to :owner, :class_name => 'Use开发者_StackOverflowr' #... changing it reassigns account ownership!
end
Diaspora uses MongoDB instead of a SQL database. As such, instead of using ActiveRecord it uses MongoMapper. The models are declared differently.
http://mongomapper.com/
https://github.com/jnunemaker/mongomapper
精彩评论