diff --git a/app/controllers/api/comments_controller.rb b/app/controllers/api/comments_controller.rb index ca74e08..88f6a2d 100644 --- a/app/controllers/api/comments_controller.rb +++ b/app/controllers/api/comments_controller.rb @@ -15,7 +15,7 @@ class Api::CommentsController < ApplicationController @comment.save - respond_with @comment + respond_with @comment, :location => api_comment_url(@comment) end #TODO Add Authorization diff --git a/config/routes.rb b/config/routes.rb index 296a6d8..6683601 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,10 @@ AsciiIo::Application.routes.draw do match ':id' => 'asciicasts#show', :constraints => { :id => /\d+/ } namespace :api do - resources :asciicasts do + resources :comments + resources :asciicasts do resources :comments - end end diff --git a/db/schema.rb b/db/schema.rb index 30e0eff..0b1e82b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -38,6 +38,17 @@ ActiveRecord::Schema.define(:version => 20120304162005) do add_index "asciicasts", ["user_id"], :name => "index_asciicasts_on_user_id" add_index "asciicasts", ["user_token"], :name => "index_asciicasts_on_user_token" + create_table "comments", :force => true do |t| + t.text "body", :null => false + t.integer "user_id", :null => false + t.integer "asciicast_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "comments", ["asciicast_id"], :name => "index_comments_on_asciicast_id" + add_index "comments", ["user_id"], :name => "index_comments_on_user_id" + create_table "user_tokens", :force => true do |t| t.integer "user_id", :null => false t.string "token", :null => false @@ -48,17 +59,6 @@ ActiveRecord::Schema.define(:version => 20120304162005) do add_index "user_tokens", ["token"], :name => "index_user_tokens_on_token" add_index "user_tokens", ["user_id"], :name => "index_user_tokens_on_user_id" - create_table "comments", :force => true do |t| - t.text "body" - t.integer "user_id" - t.integer "asciicast_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - - add_index "comments", ["asciicast_id"], :name => "index_comments_on_asciicast_id" - add_index "comments", ["user_id"], :name => "index_comments_on_user_id" - create_table "users", :force => true do |t| t.string "provider", :null => false t.string "uid", :null => false