Class: NotesController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/notes_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
# File 'app/controllers/notes_controller.rb', line 10

def create
  note = @person.notes.build(params[:note])
  note.user = current_user
  note.organization = current_user.current_organization
  note.save
  redirect_to @person
end

#destroyObject



18
19
20
21
22
23
24
25
26
# File 'app/controllers/notes_controller.rb', line 18

def destroy
  if Note.exists? params[:id]
    Note.destroy(params[:id])
    flash[:notice] = "Your note has been deleted."
  else
    flash[:notice] = "We couldn't find that note to delete."
  end
  redirect_to person_url(@person)
end

#editObject



28
29
30
31
# File 'app/controllers/notes_controller.rb', line 28

def edit
  @note = Note.find(params[:id])
  render :layout => false
end

#newObject



4
5
6
7
8
# File 'app/controllers/notes_controller.rb', line 4

def new
  @note = Note.new
  @note.occurred_at = DateTime.now.in_time_zone(current_user.current_organization.time_zone)
  render :layout => false
end

#updateObject



33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/notes_controller.rb', line 33

def update
  @note = Note.find params[:id]

  if @note.update_attributes(params[:note])
    flash[:notice] = "Note updated successfully!"
    redirect_to person_url(@person)
  else
    flash[:alert] = "There was a problem editing your note, please contact support if the problem persists."
    redirect_to :back
  end
end