Skip to content

Commit

Permalink
viewに書いていた処理をcotrollerに移動
Browse files Browse the repository at this point in the history
  • Loading branch information
djkazunoko committed Aug 26, 2023
1 parent a6b892d commit c9cf0f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/api/practices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def index
.eager_load(:practices)
.where.not(practices: { id: nil })
.order('categories_practices.position')
@unique_practices = @categories.flat_map(&:practices).uniq
end

def update
Expand Down
4 changes: 1 addition & 3 deletions app/views/api/practices/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# frozen_string_literal: true

unique_practices = @categories.flat_map(&:practices).uniq

json.array! unique_practices do |practice|
json.array! @unique_practices do |practice|
json.(practice, :id, :title)
end

0 comments on commit c9cf0f2

Please sign in to comment.