On 7/17/06, Michael Genereux <[EMAIL PROTECTED]> wrote:
I agree import is appropriate.  However, the reason someone would want
this in Rails is to integrate a CSV import through the web interface for
an end user.  Why would it skip validation though?

There are cases where skipping validation is desired: I have a set of hourly tasks that create a few hundred thousand hashes and shove them into the database.

I would expect:
1. A creation of ActiveRecord objects for all the elements in the hash.
2. Validation ran on all the objects.
3. The mass insertion method is ran against an array holding objects
that pass validation.

Would it not make more sense to stop unless the records are all valid? Are you going to ask the user to edit the valid lines out of their CSV file to avoid duplicate records? ;-)

4.  The array of those that fail would be returned to provide feedback
to the user on the offending entries.

I would think that this optimized method is trying to take advantage of
mass INSERTS into a SQL database and not circumvent the ActiveRecord
design completely.

I think there are two separate cases: one where you want to insert a *lot* of records that you know to be valid, and another to insert a bunch of records that you do not trust to be valid. In m

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to