File Uploads in Ruby on Rails

Simple File Upload Application in Ruby on Rails.
This program uploads any type of file to the uploads directory under public folder and stores the file name in database.

Procedure :-

  1. Create database fileuploads through mysql command line or phpmyadmin or Netbeans Services Tab
  2. Create new project and provide the database information
  3. Generate scaffold Upload with argument filename:string
  4. Change the code for Model upload.rb as given below
  5. Change the code for views/uploads/new.html.erb as given below
  6. Delete Public\index.html
  7. Create folder 'Uploads' under Public folder
  8. Edit the Configuration\routes.rb to point uploads controller. map.root :controller => "uploads"
  9. Migrate Database
  10. Execute the application

Model : Upload

  1. span style="color:#996600;">'public','Uploads''wb'

Views : new.html.erb

  1. span style="color:#996600;">'create'"Open File"'Upload''Back'