#691: added #show action for Users API

This commit is contained in:
Vokhmin Alexey V 2012-10-15 13:45:00 +04:00
parent a9054f24e3
commit e50bd3a2b5
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,16 @@
# -*- encoding : utf-8 -*-
class Api::V1::UsersController < Api::V1::BaseController
before_filter :authenticate_user!
skip_before_filter :authenticate_user!, :only => [:show] if APP_CONFIG['anonymous_access']
def show
@user = User.where(:id => params[:id]).first
if @user
render :show
else
render_json_response User.new, "User with id='#{params[:id]}' does not exist", 422
end
end
end

View File

@ -0,0 +1,9 @@
json.user do |json|
json.(@user, :id, :name, :email, :uname,:language, :own_projects_count, :professional_experience, :site, :company, :location)
json.created_at @user.created_at.to_i
json.updated_at @user.updated_at.to_i
json.url api_v1_user_path(@user.id, :format => :json)
json.html_url user_path(@user.uname)
end
json.url api_v1_user_path(@user.id, :format => :json)

View File

@ -39,6 +39,7 @@ Rosa::Application.routes.draw do
get :refs_list
}
end
resources :users, :only => [:show]
end
end