I think use *render :file => 'uploadfile.html.erb'*, as rails would look for the template in your view directory, which is "app/views",
and if you use render :file => 'controller/uploadfile.html.erb', it will look for the template in "app/views/controller/uploadfile.html.erb", or rails always assume you have already put your template in the controller's according view folder On Mon, Mar 29, 2010 at 12:41 PM, Tony Augustine <li...@ruby-forum.com>wrote: > when i tried to crate an upload file application in rails i am getting > error like this > > > Template is missing > > Missing template app\views\upload\uploadfile.html.erb in view path > app/views > > this is ma model > > > class DataFile < ActiveRecord::Base > def self.save(upload) > name = upload['datafile'].original_filename > directory = "public/data" > # create the file path > path = File.join(directory, name) > # write the file > File.open(path, "wb") { |f| f.write(upload['datafile'].read) } > end > end > > > > > this is ma view file > > > <h1>File Upload</h1> > <%= start_form_tag ({:action => 'uploadFile'}, > :multipart => true) %> > <p><label for="upload_file">Select File</label> : > <%= file_field 'upload', 'datafile' %></p> > <%= submit_tag "Upload" %> > <%= end_form_tag %> > > > > > This is ma controller > > class UploadController < ApplicationController > def index > puts 'hiiiiiiiiiii' > render :file => 'app\views\upload\uploadfile.html.erb' > puts 'hiiiiiiiiiii2' > end > def uploadFile > puts 'hiiiiiiiiiii3' > post = DataFile.save(params[:upload]) > render :text => "File has been uploaded successfully" > end > end > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com<rubyonrails-talk%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.