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
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
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
wheen i did that i am getting the error like this
hiiiiiiiiiii3
SQL (0.5ms) SET client_min_messages TO 'panic'
SQL (0.5ms) SET client_min_messages TO 'notice'
SQL (0.6ms) SET client_encoding TO 'unicode'
NoMethodError (You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.):