add support to create users / update instruments via API
This commit is contained in:
parent
7782938a96
commit
36f14c19d1
|
|
@ -16,12 +16,12 @@ class ApiUsersController < ApplicationController
|
|||
end
|
||||
|
||||
def create
|
||||
User.save(params)
|
||||
@user = User.save(params)
|
||||
respond_with @user, responder: ApiResponder, :location => api_user_detail_url(@user)
|
||||
end
|
||||
|
||||
def update
|
||||
User.save(params)
|
||||
@user = User.save(params)
|
||||
respond_with @user, responder: ApiResponder
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ unless @band.users.nil? || @band.users.size == 0
|
|||
node :instruments do |user|
|
||||
unless user.instruments.nil? || user.instruments.size == 0
|
||||
child :musician_instruments => :instruments do
|
||||
attributes :description, :proficiency_level
|
||||
attributes :id, :description, :proficiency_level
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,5 +21,8 @@ end
|
|||
unless @user.instruments.nil? || @user.instruments.size == 0
|
||||
child :musician_instruments => :instruments do
|
||||
attributes :description, :proficiency_level
|
||||
node :id do |instrument|
|
||||
instrument.instrument_id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -40,18 +40,31 @@ SampleApp::Application.routes.draw do
|
|||
match '/users' => 'api_users#index', :via => :get
|
||||
match '/users/:id' => 'api_users#show', :via => :get, :as => 'api_user_detail'
|
||||
match '/users' => 'api_users#create', :via => :post
|
||||
match '/users/:id' => 'api_users#update', :via => :put
|
||||
match '/users/:id' => 'api_users#update', :via => :post
|
||||
match '/users/:id' => 'api_users#destroy', :via => :delete
|
||||
|
||||
# bands
|
||||
match '/bands' => 'api_bands#index', :via => :get
|
||||
match '/bands/:id' => 'api_bands#show', :via => :get, :as => 'api_band_detail'
|
||||
=begin
|
||||
match '/bands' => 'api_bands#create', :via => :post
|
||||
match '/bands/:id' => 'api_bands#update', :via => :post
|
||||
=begin
|
||||
match '/bands/:id/followers' => 'api_bands#followers_index', :via => :get
|
||||
match '/bands/:id/musicians' => 'api_bands#musicians_index', :via => :get
|
||||
=end
|
||||
|
||||
# followers
|
||||
match '/users/:id/followers' => 'api_users#followers_index', :via => :get
|
||||
|
||||
# followings
|
||||
match '/users/:id/followings' => 'api_users#followings_index', :via => :get
|
||||
match '/users/:id/followings' => 'api_users#followings_create', :via => :post
|
||||
match '/users/:id/followings/:user_id' => 'api_users#followings_destroy', :via => :delete
|
||||
|
||||
# favorites
|
||||
match '/users/:id/favorites' => 'api_users#favorites_index', :via => :get
|
||||
match '/users/:id/favorites' => 'api_users#favorites_create', :via => :post
|
||||
match '/users/:id/favorites/:recording_id' => 'api_users#favorites_destroy', :via => :delete
|
||||
=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