blob: 7b9e4eb1fe30f41055ca6d5c04960f9d462c868e (
plain)
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
|
class NotesController < ApplicationController
protect_from_forgery with: :null_session
def index
render :json => Note.all.order(:created_at => :desc)
end
def show
render :json => Note.find(params[:id])
end
def create
note = Note.create(note_params)
render :json => note
end
def update
note = Note.find(params[:id])
note.update(note_params)
render :json => note
end
def destroy
note = Note.find(params[:id])
note.destroy
render :json => note
end
private
def note_params
params.require(:note).permit(:title, :body)
end
end
|