Dave Silvester
2005-Nov-14 00:35 UTC
Validation without ActiveRecord (was Re: contact form/no db table?)
On Sunday 13 Nov 2005 23:47, Nathaniel S. H. Brown wrote:> When you generate your model, simply remove the "< ActiveRecord::Base" > within the class definition, > [...] > You will not get all the nice features of ActiveRecord, such as find, > before_filter, etc. But from what it sounds like you are after, you don''t > really need most of them anyways.I have a question that is related to this. I too have a form that is required to get and validate some input, but this information is not to be stored in the database - it''s just needed to complete a payment transaction (handled by an external server). It''s all good an working fine - my model does not inherit from ActiveRecord. However, I have to validate the fields as they are entered, and have resorted to just coding the validations myself. I''ve seen this thread... http://wrath.rubyonrails.org/pipermail/rails/2004-December/001069.html ... and am wondering if there are any real plans to move the validations out of ActiveRecord and into a separate "ActiveValidation" (or whatever) system, that ActiveRecord could still make use of, but that could also be used separately from just validating stuff that is going into a database? It would seem to make sense, because validation is needed in a lot of situations that aren''t necessarily tied in with a database. Does anyone (DHH?) know what the longer-term plans are? In the meantime, has anyone got any really neat examples of doing their own validation on temporary input data? Mine works, but I''m sure it could probably be done better. I''ve seen this... http://wiki.rubyonrails.com/rails/pages/HowToUseValidationsWithoutExtendingActiveRecord ... but I''m not sure it suits my needs. I never call save on this model, because it really is just used to get some temporary data and pass it on. (Perhaps I''ve misunderstood the workings of that code, and it actually might work without ever calling save - I''m not sure.) Surely someone has come up with an elegant, non-kludgy way of doing this? Thanks, ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/