Normally, when using form helpers in Rails, each field directly
correlates to a method on the appropriate object.
However, I have a form (user signup) that needs to include fields that
are not part of the user model itself (for instance, card details) but
need to appear.
How can I build the form so that I can get the necessary fields, and
validate them as I need to (so that it fits with all my other
validations) without dirty-ing my user model?
Essentially I’m not building a form that directly correlates to the
model in question. For instance a signup form might incorporate some
user properties, and some “throw away” properties (such as those you
might fire at a CC gateway and then forget).
If I created attributes on my user model, I would always need to
supply those properties for validations to pass whereas I only want to
validate these items on this single form in this single location.
What’s the approach to take here?