second attempt of making favorite people view sortable

This commit is contained in:
Pfingstfrosch
2020-05-16 14:09:33 +02:00
parent f2686288b7
commit 2f6d638cd1
3 changed files with 25 additions and 4 deletions
+17 -1
View File
@@ -1,11 +1,17 @@
class FavoritesController < ApplicationController
helper_method :sort_column, :sort_direction
def people
@favorite_people = FavoritePerson.where('user_id': current_user.id)
.order(params[:sort])
.order(sort_column + " " + sort_direction)
@host = 'https://tiss.tuwien.ac.at'
end
def delete_person
FavoritePerson.find_by_tiss_id(params[:tiss_id]).destroy
redirect_back(fallback_location: people)
end
def courses
end
@@ -17,4 +23,14 @@ class FavoritesController < ApplicationController
def projects
end
private
def sort_column
params[:sort] || 'first_name'
end
def sort_direction
params[:direction] || 'asc'
end
end