blob: 226daa512a099acd139462aa17d9d458f3c416c4 (
plain) (
blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
class Admin::UpdatesController < Admin::AdminController
before_action :set_section
def new
@stream = Stream.find(params[:stream_id])
@update = @stream.updates.build
end
def create
@stream = Stream.find(params[:stream_id])
@update = @stream.updates.build(update_params)
if @update.save
flash.notice = "Update created successfully!"
render :edit
else
flash.alert = "Error creating update."
render :new
end
end
def edit
@stream = Stream.find(params[:stream_id])
@update = Update.find(params[:id])
end
def update
@stream = Stream.find(params[:stream_id])
@update = Update.find(params[:id])
if @update.update(update_params)
flash.notice = "Update updated successfully!"
else
flash.alert = "Error updating update."
end
render :edit
end
private
def update_params
params.require(:update).permit(:body, records_attributes: [:description, :_destroy])
end
def set_section
@section = "streams"
end
end
|