start of iteration 2
This commit is contained in:
parent
9fb87a74ce
commit
729ed13521
75 changed files with 705 additions and 170 deletions
64
app/controllers/pages_controller.rb
Normal file
64
app/controllers/pages_controller.rb
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
class PagesController < ApplicationController
|
||||
before_action :set_page, only: %i[ show edit update destroy ]
|
||||
before_action :set_report, only: %i[ new create index ]
|
||||
|
||||
# GET /pages
|
||||
def index
|
||||
@pages = Page.all
|
||||
end
|
||||
|
||||
# GET /pages/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /pages/new
|
||||
def new
|
||||
@page = Page.new
|
||||
@page.report = @report
|
||||
end
|
||||
|
||||
# GET /pages/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /pages
|
||||
def create
|
||||
@page = Page.new(page_params)
|
||||
@page.report = @report
|
||||
if @page.save
|
||||
redirect_to [ @page.report, page_id: @page.id ], notice: "Page was successfully created."
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /pages/1
|
||||
def update
|
||||
if @page.update(page_params)
|
||||
redirect_to @page, notice: "Page was successfully updated.", status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /pages/1
|
||||
def destroy
|
||||
@page.destroy!
|
||||
redirect_to pages_url, notice: "Page was successfully destroyed.", status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_page
|
||||
@page = Page.find(params[:id])
|
||||
end
|
||||
|
||||
def set_report
|
||||
@report = Report.find(params[:report_id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def page_params
|
||||
params.require(:page).permit(:position, :path, :url, :report_id)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue