I have a site in development that I need to customer to confirm a few
things before they can proceed to the payment page. I intend to
present them with the relevant questions and then check that they have
answered them e.g. have you read the T's & C's. Are you over 18? Are
you resident in the UK etc etc. I do not need to record these
necessarily.
Is there a simple way of validating these in the controller and then
returning the messages in the same way as Active Record would do so I
can use the same form builder as the rest of the site (I do inline
errors with ToolTip)?
I have considered just implementing a model called "Confirmation" with
a 1-1 relationship with order but I think this is a little overkill
and the number of confirmations may change over time and vary. So I
would need a to implement a confirmation answer model and a
confirmation question model. All seems a bit complex. How about just
serializing a hash as a database column with the questions as the key
and the values entered?
I agree that Booleans are cheap in terms of storage but I not really
want to keep adding database columns through the model as the number
of questions vary over time and I do not really want to go through all
of the hassle of a child table to hold them. I'm thinking of having
one (persistent) attribute on the model which is a serialized hash of
the questions and the answers. Any thoughts. Am I just being lazy?
As long as you don’t
need to query on those values (“send email to all users who haven’t yet
agreed to the latest T&Cs”), the serialization approach will work.
(and with accepts_nested_attributes_for and fields_for, how much work
is a child table, really? )
As long as you don't need to query on those values ("send email to all
users who haven't yet agreed to the latest T&Cs"), the serialization
approach will work.
It will work, but it's smelly in DB terms.
(and with accepts_nested_attributes_for and fields_for, how much work is
a child table, really? )
And with proper use of migrations, how much work is adding columns,
really?