* API Articles v0-v1 restructure * Remove unused helper * Bulk move API controllers into concerns + add V1 controllers * Extract API routes + some fixes * Fix v1 api_controller authenticate! + add more article_controller specs * Completed spec/requests/api/v1/articles_spec.rb * specs up to listings * All v1 specs except for 9 skips * mime_types cleanup + authenticate! relocation Co-authored-by: Fernando Valverde <fernando@visualcosita.com>
25 lines
631 B
Ruby
25 lines
631 B
Ruby
module Api
|
|
module UsersController
|
|
extend ActiveSupport::Concern
|
|
|
|
SHOW_ATTRIBUTES_FOR_SERIALIZATION = %i[
|
|
id username name summary twitter_username github_username website_url
|
|
location created_at profile_image registered
|
|
].freeze
|
|
|
|
def show
|
|
relation = User.joins(:profile).select(SHOW_ATTRIBUTES_FOR_SERIALIZATION)
|
|
|
|
@user = if params[:id] == "by_username"
|
|
relation.find_by!(username: params[:url])
|
|
else
|
|
relation.find(params[:id])
|
|
end
|
|
not_found unless @user.registered
|
|
end
|
|
|
|
def me
|
|
render :show
|
|
end
|
|
end
|
|
end
|