Add more artist commentary API endpoints.

* GET /posts/1/artist_commentary.json
* GET /artist_commentaries/1.json
This commit is contained in:
evazion
2016-12-21 03:34:45 -06:00
parent 254efd9ca2
commit cc215f6a41
2 changed files with 18 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
class ArtistCommentariesController < ApplicationController
respond_to :html, :xml, :json, :js
before_filter :member_only, :except => [:index]
before_filter :member_only, :except => [:index, :show]
def index
@commentaries = ArtistCommentary.search(params[:search]).order("artist_commentaries.id desc").paginate(params[:page], :limit => params[:limit])
@@ -11,6 +11,18 @@ class ArtistCommentariesController < ApplicationController
end
end
def show
if params[:id]
@commentary = ArtistCommentary.find(params[:id])
else
@commentary = ArtistCommentary.find_by_post_id!(params[:post_id])
end
respond_with(@commentary) do |format|
format.html { redirect_to post_path(@commentary.post) }
end
end
def create_or_update
@artist_commentary = ArtistCommentary.find_by_post_id(params[:artist_commentary][:post_id])

View File

@@ -193,6 +193,10 @@ Rails.application.routes.draw do
resources :pool_versions, :only => [:index]
resources :posts do
resources :events, :only => [:index], :controller => "post_events"
resource :artist_commentary, :only => [:index, :show] do
collection { put :create_or_update }
member { put :revert }
end
resources :votes, :controller => "post_votes", :only => [:create, :destroy]
collection do
get :home
@@ -216,7 +220,7 @@ Rails.application.routes.draw do
get :search
end
end
resources :artist_commentaries do
resources :artist_commentaries, :only => [:index, :show] do
collection do
put :create_or_update
get :search