Skip to content

Commit

Permalink
154: Sort lists by name when adding to a list
Browse files Browse the repository at this point in the history
  • Loading branch information
mikevallano committed Nov 30, 2019
1 parent 795de46 commit e352b27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/models/user.rb
Expand Up @@ -62,11 +62,11 @@ def all_listings
end

def lists_except_movie(movie = nil)
if movie.present? && Movie.exists?(tmdb_id: movie.tmdb_id)
@movie_lists = Movie.find_by(tmdb_id: movie.tmdb_id).lists.by_user(self)
@lists_except_movie = (all_lists - @movie_lists)
if movie.present? && existing_movie = Movie.find_by(tmdb_id: movie.tmdb_id)
(all_lists - existing_movie.lists.by_user(self))
.sort_by { |list| list.name.downcase }
else
all_lists
all_lists_by_name
end
end

Expand Down

0 comments on commit e352b27

Please sign in to comment.