L-exp Mobile

Rails does not block on file uploads

I’ve been quite annoyed with the ignorance of people who keep telling every other fucking person that Rails blocks on file upload. Guess what, I’ve got a news for you !!!

You’re fucking wrong

But things don’t stop here. One of them went ahead, tested it, and came back to me to let me know “Rails does block on file uploads.” Here’s one more news..

You don’t know how to fucking test

Here are the steps to realize Rails does not block on file uploads :

Stop reading this book :

Follow these steps :

1 2 3 null:Rails lifo$ rails fileuploads null:Rails lifo$ cd fileuploads/ null:fileuploads lifo$ script/generate controller upload index

Make your RAILS_ROOT/app/views/upload/index.html.erb look something like below :

1 2 3 4 5 <% form_tag({}, { :multipart => true }) do %> <label for="file">File to Upload</label> <%= file_field_tag "file" %> <%= submit_tag %> <% end %>

Now, generate a big fat file ( YMMV ) for testing purpose :

null:fileuploads lifo$ dd if=/dev/random of=out.txt bs=1000000 count=100
Now start the server with script/server Open http://localhost:3000/upload in two tabs Start uploading that big fat file in first tab Switch the tab to second. And start pressing refresh button !!! Last but not the least, stop bullshitting about Rails blocking on file uploads

I had written this article at least 6 months ago, but never published. Don’t take it personally.



Options:   Save This | Share
Viewed 0 times
Published 3 months ago
By pratik
From Resource has_many :bugs, :through => :rails - sleepless in london.. in lists:
Best Ruby on Rails Blogs

Menu

by Genís