diff --git a/app/controllers/api/v1/profiles_controller.rb b/app/controllers/api/v1/profiles_controller.rb new file mode 100644 index 00000000..8b791742 --- /dev/null +++ b/app/controllers/api/v1/profiles_controller.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class Api::V1::ProfilesController < ApplicationController + def home_profiles + @creator_profiles = CreatorProfile.order("RANDOM()").take(12) + end +end diff --git a/app/views/api/v1/profiles/home_profiles.json.jbuilder b/app/views/api/v1/profiles/home_profiles.json.jbuilder new file mode 100644 index 00000000..b60a709c --- /dev/null +++ b/app/views/api/v1/profiles/home_profiles.json.jbuilder @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +json.array! @creator_profiles do |creator_profile| + json.name creator_profile.name + json.slug creator_profile.slug + json.skills creator_profile.skills + json.avatar url_for(creator_profile.avatar) if creator_profile.avatar.present? +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index f3886cf6..4b33615e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,6 +55,9 @@ resources :posts do get "latest", to: "posts#latest", on: :collection end + resources :profiles do + get "home_profiles", to: "profiles#home_profiles", on: :collection + end end end