aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/concerns/.keep0
-rw-r--r--app/controllers/events_controller.rb70
-rw-r--r--app/controllers/pages_controller.rb4
4 files changed, 76 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
new file mode 100644
index 0000000..09705d1
--- /dev/null
+++ b/app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::Base
+end
diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/controllers/concerns/.keep
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
new file mode 100644
index 0000000..13c7cec
--- /dev/null
+++ b/app/controllers/events_controller.rb
@@ -0,0 +1,70 @@
+class EventsController < ApplicationController
+ before_action :set_event, only: %i[ show edit update destroy ]
+
+ # GET /events or /events.json
+ def index
+ @events = Event.all
+ end
+
+ # GET /events/1 or /events/1.json
+ def show
+ end
+
+ # GET /events/new
+ def new
+ @event = Event.new
+ end
+
+ # GET /events/1/edit
+ def edit
+ end
+
+ # POST /events or /events.json
+ def create
+ @event = Event.new(event_params)
+
+ respond_to do |format|
+ if @event.save
+ format.html { redirect_to event_url(@event), notice: "Event was successfully created." }
+ format.json { render :show, status: :created, location: @event }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @event.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /events/1 or /events/1.json
+ def update
+ respond_to do |format|
+ if @event.update(event_params)
+ format.html { redirect_to event_url(@event), notice: "Event was successfully updated." }
+ format.json { render :show, status: :ok, location: @event }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @event.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /events/1 or /events/1.json
+ def destroy
+ @event.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to events_url, notice: "Event was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_event
+ @event = Event.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def event_params
+ params.require(:event).permit(:date, :name)
+ end
+end
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
new file mode 100644
index 0000000..39848c6
--- /dev/null
+++ b/app/controllers/pages_controller.rb
@@ -0,0 +1,4 @@
+class PagesController < ApplicationController
+ def index
+ end
+end