diff options
Diffstat (limited to 'app/controllers/events_controller.rb')
| -rw-r--r-- | app/controllers/events_controller.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 96a51f0..6a8fe42 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -1,4 +1,6 @@ class EventsController < ApplicationController + before_action :load_agent + def index @events = Event.all end @@ -8,8 +10,8 @@ class EventsController < ApplicationController end def create - Publisher.publish("events", event_params) - redirect_to events_path, notice: 'Event was successfully created.' + Publisher.publish("events", event_params.merge({agent_id: @agent.id})) + redirect_to agent_events_path, notice: 'Event was successfully created.' end def destroy @@ -18,7 +20,13 @@ class EventsController < ApplicationController redirect_to events_url, notice: 'Event was successfully destroyed.' end + private + def event_params params.require(:event).permit(:name, :data) end + + def load_agent + @agent = Agent.find(params[:agent_id]) + end end |
