This is a great use case for a background job. Have you tried Resque?

If I have a user uploading thousands of rows, all of which need to be validated 
and processed/saved, I’d do it like this:
Let the user upload the file, save it somewhere. Trigger a Resque job.
Read the file one or more rows at a time, make a ActiveRecord or ActiveModel 
object out of them and run the validators. Collate the errors and include the 
row number.
If all the rows were valid, continue processing or saving.
If not, send an email to the uploader and/or show in his dashboard the failure 
message, along with a list of all errors with row numbers.

I’ve used this method in our app, and is working out great for our users.



--  
Dheeraj Kumar


On Tuesday, 5 November 2013 at 10:45 am, Fahim Patel wrote:

> @tam - I am even not sure how can experiment it.  Collecting data and 
> studying in progress.
> @sur - I am still  cross checking.. If you provide any reference link or data 
> to proof that validation already get cached.
>  
> Friends and @sur  please clear me on below question-
> From rails app, when user insert data then each time data hitted on database 
> for validation or validation is present in cache ?  
>  
> If validation get cached then we don't need move validation on cache.
>  
>  
>  
>  
> --  
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to rubyonrails-talk+unsubscr...@googlegroups.com 
> (mailto:rubyonrails-talk+unsubscr...@googlegroups.com).
> To post to this group, send email to rubyonrails-talk@googlegroups.com 
> (mailto:rubyonrails-talk@googlegroups.com).
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/rubyonrails-talk/884cb08e-d516-4144-90de-701fbabd2497%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/F7A86230F2D74DB1890C6B253A9176C5%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to