Reflexive Ruby Reaction
Ya know, I keep hearing all about how wonderful Ruby is and every once in a while I think about picking it up. But then I come across something like this and I come to my senses:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
def download dl_opts = params[:dl].nil? ? ‘attachment‘ : ‘inline‘ dl_img = params[:type].nil? ? "" : "_#{params[:type]}" dl_file = FileUpload.find_by_item_id(params[:id]) unless dl_file.nil? dl_file_type = dl_file.mime_type dl_file_ext = dl_file_type.item.self_title dl_file_name = "#{dl_file.original_name}#{dl_img}.#{dl_file_ext}" dl_file_path = "#{RAILS_ROOT}/public/upload/#{dl_file.id}/" dl_file_title = dl_file.item.self_title dl_public_name = dl_file_title == dl_file_name ? dl_file_name : "#{dl_file_title}#{dl_img}.#{dl_file_ext}" send_file("#{dl_file_path}#{dl_file_name}", :disposition => dl_opts, :encoding => ‘utf8‘, :type => dl_file_type.content_type, :filename => URI.encode(dl_public_name)) end end
Ruby makes Perl look like English. Come on. That’s not software. That’s what happens when you throw a cat at your keyboard.
Sure, maybe getting a snippet from “RefactorMyCode” is salting the dig a bit but good god.
FAIL
Tags: Programming, ruby
