Skip to content

Commit

Permalink
Sort tracks by name
Browse files Browse the repository at this point in the history
  • Loading branch information
nickskyline committed Jun 7, 2024
1 parent d38b00a commit 4161988
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/tracks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def index
@tracks = @tracks.where(name: { '$regex' => regex })
end

@tracks = Kaminari.paginate_array(@tracks).page(params[:page]).per(12)
@tracks = Kaminari.paginate_array(
@tracks.to_a.sort_by { |track| [track.name, track.stock? ? 0 : 1] }
).page(params[:page]).per(12)

respond_with @tracks do |format|
format.json { render :layout => false }
Expand Down

0 comments on commit 4161988

Please sign in to comment.