-
-
Notifications
You must be signed in to change notification settings - Fork 199
Expand file tree
/
Copy pathmember_notes_controller.rb
More file actions
42 lines (35 loc) · 1.03 KB
/
member_notes_controller.rb
File metadata and controls
42 lines (35 loc) · 1.03 KB
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
class Admin::MemberNotesController < Admin::ApplicationController
before_action :authorize_note, only: %i[update destroy]
def create
@note = MemberNote.new(member_note_params)
authorize @note
@note.author = current_user
flash[:error] = @note.errors.full_messages unless @note.save
redirect_back fallback_location: root_path
end
def edit; end
def update
if @note.update(member_note_params)
flash[:notice] = 'Note successfully updated.'
redirect_to admin_member_path(@note.member)
else
flash[:error] = @note.errors.full_messages unless @note.save
redirect_back fallback_location: root_path
end
end
def destroy
if @note.destroy
flash[:notice] = 'Note successfully deleted.'
else
flash[:error] = 'Failed to delete note.'
end
redirect_back fallback_location: root_path
end
def authorize_note
@note = MemberNote.find(params[:id])
authorize @note
end
def member_note_params
params.require(:member_note).permit(:note, :member_id)
end
end