Hi Koz,

On Wed, 2007-11-14 at 18:43 +1300, Michael Koziarski wrote:
> What bugs have you hit due to this optimisation?    Assuming that
> removing it doesn't impact too poorly on performance, and we can't
> make them ducktype nicely, then it seems reasonable to remove.


I had problems on issues of documentation and compatibility with Ruby
versions.

For example:

1. There isn't documentation on Rails to explain to programmer can
receive a StringIO or FileTemp depending on file size.

2. Depending Ruby version that you are using this could make difference
to your implementation have or not BUGS.

In Ruby version 1.8.6 this code working for all cases:

    a = parser(params[:upload_file])
  
But this code is incompatible with Ruby version 1.8.4 that I have to
make a FileTemp.open. in case I have an FileTemp then I tried something
like:

    a = parser(params[:upload_file].open)
  
   This works very well for large files, because the FileTemp has method
FileTemp.open, but will issue to the StringIO because the StringIO.open
is PRIVATE (Though in the documentation Ruby is documented as public).

  Here is the code that works well for large files and is compatible
with Ruby 1.8.4 and 1.8.6. In this case the DuckType could not be used
and it was my second attempt which I generated a BUG Blocker :-)
  
   This code working for all versions and all sizes file 
  
     if params[:upload_file].instance_of?(StringIO)
        a = parser(params[:upload_file])
     else
        a = parser(params[:upload_file].open)
     end

Looking to the code is very simple to implement, but isn't easy to
understand why this was done like that, especially for less experienced
developers.

So I advocate this optimization that the upload could be more simple
(just FileTemp) and compatible with all Ruby versions.

Cheers,

João Lins


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to