Permalink
Browse files

bugfix for initial visit

  • Loading branch information...
mck- committed Mar 9, 2012
1 parent 92bf2ed commit e4d64cadbc4065089ef48e848e302bc55a3cf9b8
Showing with 7 additions and 3 deletions.
  1. +7 −3 app/controllers/movies_controller.rb
@@ -10,15 +10,19 @@ def index
# raise session.inspect
@all_ratings = Movie.get_ratings
- if !params[:ratings]
+ if !params[:ratings] && session[:ratings]
redirect_to(movies_path({:ratings => session[:ratings], :sort => params[:sort]}))
- elsif !params[:sort]
+ elsif !params[:sort] && session[:sort]
redirect_to(movies_path({:ratings => params[:ratings], :sort => session[:sort]}))
else
@checked_ratings = params[:ratings]
session[:ratings] = @checked_ratings
session[:sort] = params[:sort]
- @movies = Movie.where(:rating => params[:ratings].keys)
+ if @checked_ratings
+ @movies = Movie.where(:rating => @checked_ratings.keys)
+ else
+ @movies = Movie.all
+ end
end
if params[:sort] == "title"

0 comments on commit e4d64ca

Please sign in to comment.