-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Survey access_code not guaranteed to be unique #45
Comments
Since one may generate surveys (and corresponding fixtures) at a very different time than importing them, looking up surveys in the database won't help the parser generate a unique access_code. Additionally, there aren't many use cases for having surveys with the same title, as users would be unable to differentiate them. If a use case is found, we'll rely on the developer to assign unique access codes with the survey method hash in the dsl. We'll add unique index on access_code in the surveys table, and a validator to the Rails model should someone create Surveys through an admin index. |
contrain surveys to have unique access_codes. closed by 572faf219240aeebcd15082bc97031f18da0117d, #42 |
Thank you for making the mods. I can clean up some of my code now. However, the indexes added for access_codes in surveys and response_sets is missing the ":unique => true". Without it, the db won't enforce uniqueness, although the model will. |
add unique indicies. closed by 660dc3f |
As there is no model validation or unique index in the database, there is no guarantee that your survey access_code will be unique. It is just a normalized version of your survey title.
Running ...
should show this to be true.
This will show both surveys as able to be taken, but will only allow the first one when the attempt is made as the survey is found by
In addition, adding a unique index to the db and model will make a mess when running
as the access_code is not unique and the survey fixtures are loaded last, leaving the associations with an invalid survey_id. To avoid this, the survey fixture should probably be attempted first.
Update...
Adding something like ...
... to Survey seems to provide a "fix" for this "problem", although I don't know how kosher it is.
It works in my test environment, but does not actually work in the "rake surveyor" task as the survey is built from a different Survey model completely and then loaded into the database and not created though the application.
My final "fix" was to add
to my Rakefile and create the file
It is not as clean as I would've liked, but works.
Of course, now you have to different surveys that probably have the same name. But at least you can take them both!
The text was updated successfully, but these errors were encountered: