Created
December 11, 2013 01:09
-
-
Save ascsystems/7903439 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Annotation | |
| include MongoMapper::Document | |
| key :quote, String | |
| key :text, String | |
| key :ranges, Array | |
| timestamps! | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class AnnotationsController < ApplicationController | |
| def index | |
| annotations = Annotation.all | |
| response.headers["Access-Control-Allow-Origin"]="*" | |
| render json: annotations | |
| end | |
| def show | |
| annotation = Annotation.find(params[:id]) | |
| response.headers["Access-Control-Allow-Origin"]="*" | |
| render json: annotation | |
| end | |
| def new | |
| annotation = Annotation.new | |
| response.headers["Access-Control-Allow-Origin"]="*" | |
| render json: annotation | |
| end | |
| def edit | |
| annotation = Annotation.find(params[:id]) | |
| end | |
| def create | |
| response.headers["Access-Control-Allow-Origin"]="*" | |
| render json: params | |
| #annotation = Annotation.new(params) | |
| #annotation = Annotation.create({quote: params[:quote], text: params[:text]}) | |
| #if annotation.save | |
| # render json: annotation, status: :created, location: annotation | |
| #else | |
| # render json: annotation.errors, status: :unprocessable_entity | |
| #end | |
| end | |
| def update | |
| annotation = Annotation.find(params[:id]) | |
| response.headers["Access-Control-Allow-Origin"]="*" | |
| if annotation.update_attributes(params) | |
| head :no_content | |
| else | |
| render json: annotation.errors, status: :unprocessable_entity | |
| end | |
| end | |
| def destroy | |
| annotation = Annotation.find(params[:id]) | |
| annotation.destroy | |
| response.headers["Access-Control-Allow-Origin"]="*" | |
| head :no_content | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Registration::Application.routes.draw do | |
| devise_for :admin_users, ActiveAdmin::Devise.config | |
| ActiveAdmin.routes(self) | |
| resources :registrations, :annotations | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment