I am writing an optics review program that has 2 types of questions.
"Static" questions are just regular questions stored in a "questions"
table along with their associated correct answers and explanations.
"Generated" questions are generated by a "method" I write. When a
generated question is picked, the method I wrote is called and it
returns an "instance" of the question, its correct answer, and its
explanation. Each time the question is called it generates a slightly
different version of the question. I plan to have hundreds of these
methods. Currently each is a separate file.
I do not know what the best approach to storing and accessing these
files/methods is. Is the a correct rails way to do this? I would
appreciate any help, even pointing me in the right direction would be a
I think I would rather store the information as a sprintf string in the same table and then grep for %s and/or add an extra column on the table that holds the type of dynamic question it is so that you can have a single method that transforms itself based on that column and then just does something like "hello %s, how are you?" % 'Jordon' but you can do that for complete phrases and such. This makes it so you have a single method for both dynamic and “static”… Or you could do that with I18n but I still prefer to keep those in the database and cache them into memory as I pull them out of the database.