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. Apparently, this situation also comes up when setting up basic search forms for your website as well (http://railscasts.com/episodes/37-simple-search-form); unfortunately, Ryan didn't address it.
Essentially we're looking at this situation in the checkout view: <% form_for(@checkout, :url => "/checkout") do |f| %> <%= f.text_field :first_name %> <%= f.text_field :last_name %> <%= text_field(:cc, :card) %> <%= text_field(:cc, :expiration_date) %> <% end %> But when the model is saved, the :card and :expiration_date fields are not validated because they're not part of the model (they are accessed using params[:cc][:card] and params[:cc][:expiration_date]). All this code works - I just need to validate my credit card stuff! How do I do this? I know I'm not the first guy to run into this problem. Thank you for any suggestions! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

