summaryrefslogtreecommitdiff
path: root/app/controllers/events_controller.rb
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-02-02 21:42:47 -0700
committermo khan <mo@mokhan.ca>2015-02-02 21:42:47 -0700
commitd62b071aa28ee7ece0393cc2fa8ac42d2b981ae0 (patch)
tree6c527c36428fc1cb10a5d8a7f124380e0792febb /app/controllers/events_controller.rb
parent5402200c3b6a83869a77f35b2ef9911096942dd4 (diff)
publish message to rabbit to instead of creating a new event.
Diffstat (limited to 'app/controllers/events_controller.rb')
-rw-r--r--app/controllers/events_controller.rb29
1 files changed, 10 insertions, 19 deletions
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb
index 63ca73d..f5b7b0c 100644
--- a/app/controllers/events_controller.rb
+++ b/app/controllers/events_controller.rb
@@ -24,17 +24,8 @@ class EventsController < ApplicationController
# POST /events
# POST /events.json
def create
- @event = Event.new(event_params)
-
- respond_to do |format|
- if @event.save
- format.html { redirect_to @event, notice: 'Event was successfully created.' }
- format.json { render :show, status: :created, location: @event }
- else
- format.html { render :new }
- format.json { render json: @event.errors, status: :unprocessable_entity }
- end
- end
+ Publisher.publish("events", event_params)
+ redirect_to events_path, notice: 'Event was successfully created.'
end
# PATCH/PUT /events/1
@@ -62,13 +53,13 @@ class EventsController < ApplicationController
end
private
- # Use callbacks to share common setup or constraints between actions.
- def set_event
- @event = Event.find(params[:id])
- end
+ # Use callbacks to share common setup or constraints between actions.
+ def set_event
+ @event = Event.find(params[:id])
+ end
- # Never trust parameters from the scary internet, only allow the white list through.
- def event_params
- params.require(:event).permit(:name, :data)
- end
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def event_params
+ params.require(:event).permit(:name, :data)
+ end
end