我正在使用此file uploader example for Ruby on Rail。Ruby on Rails,:通知
我在我的控制器中有這段代碼。我需要有一個:通知參數的地方,所以當文件被上傳的通知,將「你已經上傳的文件」,如果有那麼一個錯誤「出事了」
def create
p_attr=params[:upload]
p_attr[:arraydb] = params[:upload][:upload].first if params[:upload][:upload].class == Array
@upload = Upload.new(p_attr)
respond_to do |format|
if @upload.save
@upload.update_attributes(:user_id => current_user.id)
format.html {
render :json => [@upload.to_jq_upload].to_json,
:layout => false
}
format.json { render json: [@upload.to_jq_upload].to_json, status: :created, location: @upload }
else
format.html { render action 'new' }
format.json{ render json: {name:(@upload.upload_file_name).split(".").first ,error: @upload.errors.messages[:upload_file_name]}, :status =>422}
end
end
end
所以,我需要的東西是這樣的:
format.html { redirect_to(@upload, :notice => "LALALALALALA") }
,但我不知道如何整合:注意到了我的代碼提前
感謝。
您的解決方案'format.html {redirect_to時(@upload,:通知=> 「LALALALALALA」)}'只是工作,究竟是什麼問題 ? – Khaled 2013-02-15 18:37:18
我需要將此解決方案整合到def中,創建 – Tonja 2013-02-15 19:37:48