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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.