Validating non-model forms - a predicament

Patrick L. wrote:

Hey folks,
I have encountered what's beginning to look like a classic problem with
Rails: validating non-model forms. Under what circumstances do you need
to use non-model components in a model-backed form? I need to for credit
card processing: I want to save information like the customer's phone
number but I don't want to save their credit card number for security
reasons.

Add attr_accessor :cc_number to your model, then validate it.

Then call .save(false) when saving the model object internally, to bypass all your validations.

Everything will work as if you had a column with that name, except find_by_cc_number, or loading the number (natch).

Also f.text_field will work, so Card.new(params[:card]) will work.