summaryrefslogtreecommitdiff
path: root/app/controllers/downloads_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/downloads_controller.rb')
-rw-r--r--app/controllers/downloads_controller.rb74
1 files changed, 74 insertions, 0 deletions
diff --git a/app/controllers/downloads_controller.rb b/app/controllers/downloads_controller.rb
new file mode 100644
index 0000000..300d0b1
--- /dev/null
+++ b/app/controllers/downloads_controller.rb
@@ -0,0 +1,74 @@
+class DownloadsController < ApplicationController
+ before_action :set_download, only: [:show, :edit, :update, :destroy]
+
+ # GET /downloads
+ # GET /downloads.json
+ def index
+ @downloads = Download.all
+ end
+
+ # GET /downloads/1
+ # GET /downloads/1.json
+ def show
+ end
+
+ # GET /downloads/new
+ def new
+ @download = Download.new
+ end
+
+ # GET /downloads/1/edit
+ def edit
+ end
+
+ # POST /downloads
+ # POST /downloads.json
+ def create
+ @download = Download.new(download_params)
+
+ respond_to do |format|
+ if @download.save
+ format.html { redirect_to @download, notice: 'Download was successfully created.' }
+ format.json { render :show, status: :created, location: @download }
+ else
+ format.html { render :new }
+ format.json { render json: @download.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /downloads/1
+ # PATCH/PUT /downloads/1.json
+ def update
+ respond_to do |format|
+ if @download.update(download_params)
+ format.html { redirect_to @download, notice: 'Download was successfully updated.' }
+ format.json { render :show, status: :ok, location: @download }
+ else
+ format.html { render :edit }
+ format.json { render json: @download.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /downloads/1
+ # DELETE /downloads/1.json
+ def destroy
+ @download.destroy
+ respond_to do |format|
+ format.html { redirect_to downloads_url, notice: 'Download was successfully destroyed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_download
+ @download = Download.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def download_params
+ params.require(:download).permit(:name, :filename, :type, :description, :hits)
+ end
+end