app/controllers/phcscriptcdn/scriptcdn/scripturls_controller.rb in phcscriptcdn-0.2.5 vs app/controllers/phcscriptcdn/scriptcdn/scripturls_controller.rb in phcscriptcdn-0.5.5

- old
+ new

@@ -36,52 +36,52 @@ # POST Scriptcdn_script URL def create @scriptcdn_script = Scriptcdn::Script.find(params[:script_id]) @scriptcdn_scripturl = @scriptcdn_script.scripturls.create(scriptcdn_scripturl_params) respond_to do |format| - if @scriptcdn_scripturl.save - format.html { redirect_to scriptcdn_script_scripturls_path, notice: 'Comment for Scriptcdn_script was Successfully Created.' } - format.json { render action: 'show', status: :created, location: @scriptcdn_scripturl } - else - format.html { render action: 'new' } - format.json { render json: @scriptcdn_scripturl.errors, status: :unprocessable_entity } + if @scriptcdn_scripturl.save + format.html { redirect_to scriptcdn_script_scripturls_path, notice: 'Script URL was Successfully Created.' } + format.json { render action: 'show', status: :created, location: @scriptcdn_scripturl } + else + format.html { render action: 'new' } + format.json { render json: @scriptcdn_scripturl.errors, status: :unprocessable_entity } end end end # PATCH/PUT Scriptcdn_script URL def update respond_to do |format| - if @scriptcdn_scripturl.update(scriptcdn_scripturl_params) - format.html { redirect_to scriptcdn_script_scripturls_path, notice: 'Comment for Scriptcdn_script was Successfully Updated.' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @scriptcdn_scripturl.errors, status: :unprocessable_entity } + if @scriptcdn_scripturl.update(scriptcdn_scripturl_params) + format.html { redirect_to scriptcdn_script_scripturls_path, notice: 'Script URL was Successfully Updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @scriptcdn_scripturl.errors, status: :unprocessable_entity } end end end # Delete Scriptcdn_script URL def destroy - @scriptcdn_script = Scriptcdn_script.find(params[:script_id]) + @scriptcdn_script = Scriptcdn::Script.find(params[:script_id]) @scriptcdn_scripturl = @scriptcdn_script.scripturls.find(params[:id]) @scriptcdn_scripturl.destroy respond_to do |format| - format.html { redirect_to scriptcdn_script_scripturls_path, notice: 'Comment for Scriptcdn_script was Successfully Deleted.' } + format.html { redirect_to scriptcdn_script_scripturls_path, notice: 'Script URL was Successfully Deleted.' } format.json { head :no_content } end end private # Callback def set_scriptcdn_scripturl - @scriptcdn_scripturl = Scriptcdn::Script.find(params[:id]) + @scriptcdn_scripturl = Scriptcdn::Scripturl.find(params[:id]) end # Whitelist def scriptcdn_scripturl_params - params.require(:scriptcdn_scripturl).permit(:scrpturlname, :scrpturlphc, :scrpturltype, :scriptversion_id) + params.require(:scriptcdn_scripturl).permit(:scrpturlname, :scrpturlphc, :scrpturltype, :scriptversion_id, :script_id) end end end