App001 a/d sorting for 7 columns in view selector

Thought this might be a bit tricky, but not too bad.
Could be dried up more, but that's not unusual.

    @percentage_sort_direction  = 'A' # default, stops errors and also works for the 'else' of the if's
    @year_sort_direction        = 'A' 
    if (params[:sort_column]) == "percentage"
      if (params[:sort_percentage_asc_or_desc]) # prevents error.
        if (params[:sort_percentage_asc_or_desc]).upcase == 'A'
          { @the_sort = 'percentage ASC', @percentage_sort_direction = 'D' }
          @the_sort = 'percentage DESC'
        @the_sort = @the_sort + ', year DESC, statistics_month_id ASC, browser_version_id DESC, operating_system_id DESC, resolution_id DESC, color_depth_id DESC'
    elsif (params[:sort_column]) == 'by_year' 

plus in view:
<%= link_to '%', :sort_percentage_asc_or_desc => @percentage_sort_direction, :sort_column => 'percentage', :resolution => params[:resolution], :color => params[:color], :browser => params[:browser], :os_source => params[:os_source] %>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s