Skip to content

Commit

Permalink
Add Endpoint for creators
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhbhatia committed Jan 3, 2025
1 parent 81f8fc0 commit 987f5cb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/api/v1/profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/views/api/v1/profiles/home_profiles.json.jbuilder
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 987f5cb

Please sign in to comment.