Skip to content

Commit

Permalink
Default sort type should work with all mapped columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
eric committed Mar 30, 2009
1 parent 9b4f9d2 commit a58d89e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/sortable_table/app/controllers/application_controller.rb
Expand Up @@ -42,12 +42,13 @@ def define_sort_order(acceptable_columns, mappings)
direction = default_sort_direction(params[:order], default)
column = params[:sort] || default_sort_column
self.sortable_table_direction = direction
if params[:sort] && acceptable_columns.include?(column)
column = mappings[column.to_sym] || column
handle_compound_sorting(column, sql_sort_direction(direction))
else
"#{acceptable_columns.first} #{sql_sort_direction(direction)}"

if !params[:sort] || !acceptable_columns.include?(column)
column = acceptable_columns.first
end

column = mappings[column.to_sym] || column
handle_compound_sorting(column, sql_sort_direction(direction))
end

helper_method :sort_order, :default_sort_column, :sortable_table_direction
Expand Down

0 comments on commit a58d89e

Please sign in to comment.