main
1class DispositionsController < ApplicationController
2 before_action :set_disposition, only: [:show, :edit, :update, :destroy]
3
4 def index
5 @dispositions = Disposition.all.order(:fingerprint)
6 end
7
8 def show
9 end
10
11 def new
12 @disposition = Disposition.new
13 @states = Disposition.states
14 end
15
16 def edit
17 @states = Disposition.states
18 end
19
20 def create
21 publish(PokeMessage.new(
22 fingerprint: disposition_params[:fingerprint],
23 state: disposition_params[:state],
24 ))
25
26 redirect_to dispositions_path, notice: 'Disposition was successfully created.'
27 end
28
29 def update
30 publish(PokeMessage.new(
31 fingerprint: disposition_params[:fingerprint],
32 state: disposition_params[:state],
33 ))
34 redirect_to dispositions_path, notice: 'Disposition was successfully updated.'
35 end
36
37 def destroy
38 @disposition.destroy
39 redirect_to dispositions_url, notice: 'Disposition was successfully destroyed.'
40 end
41
42 private
43
44 def set_disposition
45 @disposition = Disposition.find_by(fingerprint: params[:id])
46 end
47
48 def disposition_params
49 params.require(:disposition).permit(:fingerprint, :state)
50 end
51end