aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-11-11 16:33:24 +0000
committerMatthew Lemon <y@yulqen.org>2024-11-11 16:33:24 +0000
commitb8d7a7cf7e78fe384c6c6e8e6812a252084ce1f0 (patch)
tree5ef297ac23775afb1bcffb68265749d08f282297 /app/controllers
parent97201e0bca203b6b303789374ffd7e4228e062a7 (diff)
Adds first pdfresource model
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/pdfresources_controller.rb70
1 files changed, 70 insertions, 0 deletions
diff --git a/app/controllers/pdfresources_controller.rb b/app/controllers/pdfresources_controller.rb
new file mode 100644
index 0000000..068b61a
--- /dev/null
+++ b/app/controllers/pdfresources_controller.rb
@@ -0,0 +1,70 @@
+class PdfresourcesController < ApplicationController
+ before_action :set_pdfresource, only: %i[ show edit update destroy ]
+
+ # GET /pdfresources or /pdfresources.json
+ def index
+ @pdfresources = Pdfresource.all
+ end
+
+ # GET /pdfresources/1 or /pdfresources/1.json
+ def show
+ end
+
+ # GET /pdfresources/new
+ def new
+ @pdfresource = Pdfresource.new
+ end
+
+ # GET /pdfresources/1/edit
+ def edit
+ end
+
+ # POST /pdfresources or /pdfresources.json
+ def create
+ @pdfresource = Pdfresource.new(pdfresource_params)
+
+ respond_to do |format|
+ if @pdfresource.save
+ format.html { redirect_to @pdfresource, notice: "Pdfresource was successfully created." }
+ format.json { render :show, status: :created, location: @pdfresource }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @pdfresource.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /pdfresources/1 or /pdfresources/1.json
+ def update
+ respond_to do |format|
+ if @pdfresource.update(pdfresource_params)
+ format.html { redirect_to @pdfresource, notice: "Pdfresource was successfully updated." }
+ format.json { render :show, status: :ok, location: @pdfresource }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @pdfresource.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /pdfresources/1 or /pdfresources/1.json
+ def destroy
+ @pdfresource.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to pdfresources_path, status: :see_other, notice: "Pdfresource was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_pdfresource
+ @pdfresource = Pdfresource.find(params.expect(:id))
+ end
+
+ # Only allow a list of trusted parameters through.
+ def pdfresource_params
+ params.expect(pdfresource: [ :name, :stripe_product_id, :price, :age_range, :curriculum, :feature_slot, :description, :card_description, pdfs: [], thumbnails: [] ])
+ end
+end