Created
June 3, 2010 13:58
-
-
Save jacqui/423921 to your computer and use it in GitHub Desktop.
Using embedded documents to store field data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Field | |
include MongoMapper::EmbeddedDocument | |
key :name, String | |
key :label, String, :required => true | |
key :helper_text, String | |
key :required, Boolean, :default => false | |
key :widget, String, :required => true | |
key :options, Array # => [[value, label], [value, label], [value, label]] | |
key :selected, String | |
key :word_limit, Integer, :default => 0 | |
key :position, Integer, :default => 0 | |
key :form_id, BSON::ObjectID | |
belongs_to :form | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Form | |
include MongoMapper::Document | |
key :name, String, :required => true, :unique => true | |
# additional fields for the form... | |
many :fields, :order => 'position' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment