Skip to content
Snippets Groups Projects
Commit ba3be020 authored by Treadway, Ross T (UG - Computer Science)'s avatar Treadway, Ross T (UG - Computer Science)
Browse files

Adding my_created_events, and my_event

parent 055497b3
Branches 42-views-and-layouts
No related tags found
No related merge requests found
...@@ -7,6 +7,25 @@ class EventsController < ApplicationController ...@@ -7,6 +7,25 @@ class EventsController < ApplicationController
render json: @events render json: @events
end end
def my_created_events
events = Event.where(creator: params["id"])
if events.empty?
render json: {"error": "no events found"}, status: :not_found
else
render json: events
end
end
def my_events
id = params["id"]
events = Event.where("? = ANY (invitees)", id)
if events.empty?
render json: {"error": "no events found"}, status: :not_found
else
render json: events
end
end
# GET /events/1 # GET /events/1
def show def show
render json: @event render json: @event
......
class Event < ApplicationRecord class Event < ApplicationRecord
#TODO: validation
end end
...@@ -7,6 +7,8 @@ Rails.application.routes.draw do ...@@ -7,6 +7,8 @@ Rails.application.routes.draw do
post "events", to: "events#create" post "events", to: "events#create"
put "events", to: "events#update" put "events", to: "events#update"
delete "events", to: "events#destroy" delete "events", to: "events#destroy"
post "my_created_events", to: "events#my_created_events"
post "my_events", to: "events#my_events"
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment