forked from fulcrum-agile/fulcrum
-
Notifications
You must be signed in to change notification settings - Fork 2
/
notes_controller.rb
36 lines (32 loc) · 993 Bytes
/
notes_controller.rb
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
class NotesController < ApplicationController
def index
@project = current_user.projects.find(params[:project_id])
@story = @project.stories.find(params[:story_id])
@notes = @story.notes
render :json => @notes
end
def show
@project = current_user.projects.find(params[:project_id])
@story = @project.stories.find(params[:story_id])
@note = @story.notes.find(params[:id])
render :json => @note
end
def destroy
@project = current_user.projects.find(params[:project_id])
@story = @project.stories.find(params[:story_id])
@note = @story.notes.find(params[:id])
@note.destroy
head :ok
end
def create
@project = current_user.projects.find(params[:project_id])
@story = @project.stories.find(params[:story_id])
@note = @story.notes.build(params[:note])
@note.user = current_user
if @note.save
render :json => @note
else
render :json => @note, :status => :unprocessable_entity
end
end
end