diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/notes.coffee | 3 | ||||
-rw-r--r-- | app/assets/stylesheets/notes.scss | 3 | ||||
-rw-r--r-- | app/controllers/notes_controller.rb | 34 | ||||
-rw-r--r-- | app/helpers/notes_helper.rb | 2 | ||||
-rw-r--r-- | app/models/note.rb | 2 |
5 files changed, 44 insertions, 0 deletions
diff --git a/app/assets/javascripts/notes.coffee b/app/assets/javascripts/notes.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/notes.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/notes.scss b/app/assets/stylesheets/notes.scss new file mode 100644 index 0000000..56d31f5 --- /dev/null +++ b/app/assets/stylesheets/notes.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the notes controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb new file mode 100644 index 0000000..7b9e4eb --- /dev/null +++ b/app/controllers/notes_controller.rb @@ -0,0 +1,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 diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb new file mode 100644 index 0000000..8078f73 --- /dev/null +++ b/app/helpers/notes_helper.rb @@ -0,0 +1,2 @@ +module NotesHelper +end diff --git a/app/models/note.rb b/app/models/note.rb new file mode 100644 index 0000000..1b03bd6 --- /dev/null +++ b/app/models/note.rb @@ -0,0 +1,2 @@ +class Note < ActiveRecord::Base +end |