Skip to content

Commit

Permalink
Update Genres
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabhbhatia committed Dec 14, 2024
1 parent 00fc96f commit f4473e4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/controllers/api/v1/genres_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

class Api::V1::GenresController < ApplicationController
def index
@genres = Genre.published
end
end
6 changes: 6 additions & 0 deletions app/views/api/v1/genres/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

json.array! @genres do |genre|
json.name genre.name
json.slug genre.slug
end
7 changes: 5 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@

namespace :api do
namespace :v1 do
get "new_releases", to: "products#new_releases", as: "new_releases"
get "top_ten", to: "products#top_ten", as: "top_ten"
resources :products do
get "new_releases", to: "products#new_releases", on: :collection
get "top_ten", to: "products#top_ten", on: :collection
end
resources :genres, only: :index
end
end

Expand Down

0 comments on commit f4473e4

Please sign in to comment.