def index format params sort session sort ratings params ratings sessi

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def index
format = params[:sort] || session[:sort]
ratings = params[:ratings] || session[:ratings]
page_state_params = {}
session[:sort] = params[:sort] unless params[:sort].nil?
session[:ratings] = params[:ratings] unless params[:ratings].nil?
update_selected_ratings(ratings)
if params[:sort].nil?
page_state_params[:sort] = session[:sort]
else
page_state_params[:sort] = params[:sort]
end
if params[:ratings].nil?
page_state_params[:ratings] = session[:ratings]
else
page_state_params[:ratings] = params[:ratings]
end
diff = session.keys - params.keys
redirect_to movies_path(page_state_params) if diff.include? ("ratings") or diff.include? ("sort")
@movies = Movie.find(:all, :conditions => ["rating IN (?)", @selected_rating], :order =>format)
@all_ratings = Movie.collect_ratings
eval %Q{
@#{format}_header="hilite"
}
end