initial musician / band dev
This commit is contained in:
parent
374ca96153
commit
431367ea08
|
|
@ -0,0 +1,7 @@
|
|||
class ApiBandsController < ApplicationController
|
||||
|
||||
before_filter :signed_in_user, only: [:index, :edit, :update, :delete]
|
||||
|
||||
respond_to :json
|
||||
|
||||
end
|
||||
|
|
@ -16,14 +16,15 @@ class ApiUsersController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
@user = User.new()
|
||||
@user.email = params[:email]
|
||||
@user.creator = current_user
|
||||
@user.description = params[:description]
|
||||
@user.save
|
||||
User.save(params)
|
||||
respond_with @user, responder: ApiResponder, :location => api_user_detail_url(@user)
|
||||
end
|
||||
|
||||
def update
|
||||
User.save(params)
|
||||
respond_with @user, responder: ApiResponder
|
||||
end
|
||||
|
||||
def delete
|
||||
@user = User.find(params[:id])
|
||||
@user.delete
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
collection @users
|
||||
|
||||
extends "api_users/show"
|
||||
# do not retrieve all child collections when showing a list of users
|
||||
attributes :id, :name, :email, :online, :musician, :photo_url
|
||||
|
|
@ -1,7 +1,21 @@
|
|||
object @user
|
||||
|
||||
attributes :id, :name, :email, :admin, :online
|
||||
attributes :id, :name, :email, :online, :musician, :photo_url
|
||||
|
||||
child :friends => :friends do
|
||||
attributes :id, :name, :online
|
||||
unless @user.friends.nil? || @user.friends.size == 0
|
||||
child :friends => :friends do
|
||||
attributes :id, :name, :online
|
||||
end
|
||||
end
|
||||
|
||||
unless @user.bands.nil? || @user.bands.size == 0
|
||||
child :bands => :bands do
|
||||
attributes :id, :name
|
||||
end
|
||||
end
|
||||
|
||||
unless @user.instruments.nil? || @user.instruments.size == 0
|
||||
child :instruments => :instruments do
|
||||
attributes :id, :description, :proficiency_level
|
||||
end
|
||||
end
|
||||
|
|
@ -43,6 +43,15 @@ SampleApp::Application.routes.draw do
|
|||
match '/users/:id' => 'api_users#update', :via => :put
|
||||
match '/users/:id' => 'api_users#destroy', :via => :delete
|
||||
|
||||
# bands
|
||||
=begin
|
||||
match '/bands' => 'api_bands#index', :via => :get
|
||||
match '/bands/:id' => 'api_bands#show' :via => :get, :as => 'api_band_detail'
|
||||
match '/bands' => 'api_bands#create', :via => :post
|
||||
match '/bands/:id' => 'api_bands#update', :via => :put
|
||||
match '/bands/:id/members' => 'api_bands#members_index', :via => :get
|
||||
=end
|
||||
|
||||
# friend requests
|
||||
match '/users/:id/friend_requests' => 'api_users#friend_request_index', :via => :get
|
||||
match '/friend_requests/:id' => 'api_users#friend_request_show', :via => :get, :as => 'api_friend_request_detail'
|
||||
|
|
|
|||
Loading…
Reference in New Issue