aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/events_controller.rb2
-rw-r--r--app/controllers/organisations_controller.rb70
2 files changed, 71 insertions, 1 deletions
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
index 058486d..d819632 100644
--- a/app/controllers/events_controller.rb
+++ b/app/controllers/events_controller.rb
@@ -67,6 +67,6 @@ class EventsController < ApplicationController
# Only allow a list of trusted parameters through.
def event_params
- params.require(:event).permit(:date, :name)
+ params.require(:event).permit(:date, :name, :organisation_id)
end
end
diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb
new file mode 100644
index 0000000..dbff777
--- /dev/null
+++ b/app/controllers/organisations_controller.rb
@@ -0,0 +1,70 @@
+class OrganisationsController < ApplicationController
+ before_action :set_organisation, only: %i[ show edit update destroy ]
+
+ # GET /organisations or /organisations.json
+ def index
+ @organisations = Organisation.all
+ end
+
+ # GET /organisations/1 or /organisations/1.json
+ def show
+ end
+
+ # GET /organisations/new
+ def new
+ @organisation = Organisation.new
+ end
+
+ # GET /organisations/1/edit
+ def edit
+ end
+
+ # POST /organisations or /organisations.json
+ def create
+ @organisation = Organisation.new(organisation_params)
+
+ respond_to do |format|
+ if @organisation.save
+ format.html { redirect_to organisation_url(@organisation), notice: "Organisation was successfully created." }
+ format.json { render :show, status: :created, location: @organisation }
+ else
+ format.html { render :new, status: :unprocessable_entity }
+ format.json { render json: @organisation.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /organisations/1 or /organisations/1.json
+ def update
+ respond_to do |format|
+ if @organisation.update(organisation_params)
+ format.html { redirect_to organisation_url(@organisation), notice: "Organisation was successfully updated." }
+ format.json { render :show, status: :ok, location: @organisation }
+ else
+ format.html { render :edit, status: :unprocessable_entity }
+ format.json { render json: @organisation.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /organisations/1 or /organisations/1.json
+ def destroy
+ @organisation.destroy!
+
+ respond_to do |format|
+ format.html { redirect_to organisations_url, notice: "Organisation was successfully destroyed." }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_organisation
+ @organisation = Organisation.find(params[:id])
+ end
+
+ # Only allow a list of trusted parameters through.
+ def organisation_params
+ params.require(:organisation).permit(:name)
+ end
+end