Upload files in directory

I use Rails 3.2.2 and i created a web application.
I want to upload files and save them in assets directory and save its
locations in DB.
how can i do that?

Start by googling for
rails file upload
Then when you see the options and have looked over them come back if
you need clarifications or recommendations.

Colin

I have already tried and saved the uploaded files in directory but Not
save it's path in DB.
this is the error >> Couldn't find Resource with ID=uploadFile.
this is my controller and view

  def uploadFile
    @text = params[:upload]
    @file=@text['datafile'].original_filename

    name = @file
    directory = "public/data"
    # create the file path
    path = File.join(directory, name)
    # write the file
    File.open(path, "wb") { |f| f.write(@text['datafile'].read) }
    redirect_to(:actions=>'new')
  end