Skip to content

Commit

Permalink
prevent infinite redirects when sorting without filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mbdriscoll committed Feb 9, 2012
1 parent 52f9f0e commit 4051607
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/controllers/movies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ def index
@all_ratings = Movie.all_ratings
@selected_ratings = params[:ratings] || session[:ratings] || {}

if params[:sort] != session[:sort] or params[:ratings] != session[:ratings]
if params[:sort] != session[:sort]
session[:sort] = sort
redirect_to :sort => sort, :ratings => @selected_ratings and return
end

if params[:ratings] != session[:ratings] and @selected_ratings != {}
session[:sort] = sort
session[:ratings] = @selected_ratings
redirect_to :sort => sort, :ratings => @selected_ratings and return
Expand Down

0 comments on commit 4051607

Please sign in to comment.