Created
April 5, 2013 12:35
-
-
Save sharipov-ru/5318975 to your computer and use it in GitHub Desktop.
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
100.times do | |
user = FactoryGirl.create(:user) | |
form = FactoryGirl.create(:form) | |
# Example usage of a Submissions-storage to read/write submissions (user answers) | |
# It let us don't care much in application how would storage work and which database it uses | |
# Write a value to storage | |
# | |
# user.storage_for(form.token).store(key, value) | |
# | |
# or | |
# | |
# user.storage_for(form.token).store(array_with_fields) | |
# | |
# Get list of filled forms for user: | |
# | |
# user.storage_for(form.token).list | |
# | |
# Get list of fields with values for particular form: | |
# | |
# user.storage_for(form.token).values | |
# Filling out record extensions data for user: | |
# Storage will write it somewhere (MySQL, MongoDB) | |
user.storage_for(form.token).store([ | |
{ type: "NumberField", label: "Mother's name", value: 'Nikki' }, | |
{ type: "NumberField", label: "Father's name", value: 'Matt' }, | |
{ type: "TextField", label: "Mother's age", value: '29' }, | |
{ type: "TextField", label: "Father's age", value: '30' }, | |
] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was thinking of maybe creating a DSL for forms/record extensions.