Abder-Rahman Ali wrote:
> Is "upload" here the same as the passed argument?

Yes. Just to be clear, the code here is:

  def self.save(upload)
    name =  upload['datafile'].original_filename

> And, what about ['datafile'], what does it represent here?

It's a method call on the object passed as upload. You are calling the 
method called '[]', and passing the string 'datafile' as the argument.

What this actually does, depends on what the object 'upload' is. All you 
can tell from the above is that it implements a method called [] which 
takes a string argument. It could be a Hash, for example, in which case 
upload['datafile'] would retrieve the value keyed by 'datafile'.

But it could be some other custom object. For example:

class Foo
  def [](key)
    puts "Called [] with key #{key.inspect}"
    "hello"
  end
end

f = Foo.new
result = f["datafile"]  # Called [] with key "datafile"
puts result             # hello

That's the joy of duck-typing. You don't care what class an object is, 
only what methods it responds to.
-- 
Posted via http://www.ruby-forum.com/.