mirror of
https://github.com/edcommonwealth/Dashboard.git
synced 2026-03-13 09:00:25 -07:00
set up example scaffold with rspec + factorybot tests
This commit is contained in:
parent
533c921a6d
commit
d1e6fb1e39
23 changed files with 512 additions and 6 deletions
60
app/controllers/dashboard/examples_controller.rb
Normal file
60
app/controllers/dashboard/examples_controller.rb
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
module Dashboard
|
||||
class ExamplesController < ApplicationController
|
||||
before_action :set_example, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /examples
|
||||
def index
|
||||
@examples = Example.all
|
||||
end
|
||||
|
||||
# GET /examples/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /examples/new
|
||||
def new
|
||||
@example = Example.new
|
||||
end
|
||||
|
||||
# GET /examples/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /examples
|
||||
def create
|
||||
@example = Example.new(example_params)
|
||||
|
||||
if @example.save
|
||||
redirect_to @example, notice: "Example was successfully created."
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /examples/1
|
||||
def update
|
||||
if @example.update(example_params)
|
||||
redirect_to @example, notice: "Example was successfully updated.", status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /examples/1
|
||||
def destroy
|
||||
@example.destroy!
|
||||
redirect_to examples_url, notice: "Example was successfully destroyed.", status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_example
|
||||
@example = Example.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def example_params
|
||||
params.require(:example).permit(:text, :body)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue