blob: 6a8fe42555983c9d1956d0654b633c41ddbf54a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
class EventsController < ApplicationController
before_action :load_agent
def index
@events = Event.all
end
def new
@event = Event.new
end
def create
Publisher.publish("events", event_params.merge({agent_id: @agent.id}))
redirect_to agent_events_path, notice: 'Event was successfully created.'
end
def destroy
@event = Event.find(params[:id])
@event.destroy
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
|