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 :-
- Create database fileuploads through mysql command line or phpmyadmin or Netbeans Services Tab
- Create new project and provide the database information
- Generate scaffold
Upload
with argumentfilename:string
- Change the code for Model upload.rb as given below
- Change the code for views/uploads/new.html.erb as given below
- Delete Public\index.html
- Create folder 'Uploads' under Public folder
- Edit the Configuration\routes.rb to point uploads controller.
map.root :controller => "uploads"
- Migrate Database
- Execute the application
Model : Upload
span style="color:#996600;">'public','Uploads''wb'Views : new.html.erb
span style="color:#996600;">'create'"Open File"'Upload''Back'