While working on my controller, I attempted to render vanilla JavaScript but encountered an unexpected outcome. Below is the code snippet:
class UploadController < ApplicationController
def index
render :file => 'app\views\upload\uploadfile.rhtml'
end
def uploadFile
render :js => "alert('Hello Rails');"
post = DataFile.save(params[:upload])
end
end
Prior to executing post = DataFile.save(params[:upload]), I expected to see an alert box, but instead, I am seeing a download box. What could be causing this issue?