Sorting the Project column by project name now
* Including projects in Rate.history_for_user * Moved the valid sort options to a constant on the RatesController * Changed the ValidSortOptions to use the Project name for project_id * Updated admin view to use RatesController::ValidSortOptions instead of a duplicated string. #1915
This commit is contained in:
@@ -7,11 +7,13 @@ class RatesController < ApplicationController
|
||||
before_filter :require_user_id, :only => [:index, :new]
|
||||
before_filter :set_back_url, :only => [:new, :edit]
|
||||
|
||||
ValidSortOptions = {'date_in_effect' => "#{Rate.table_name}.date_in_effect", 'project_id' => "#{Project.table_name}.name"}
|
||||
|
||||
# GET /rates?user_id=1
|
||||
# GET /rates.xml?user_id=1
|
||||
def index
|
||||
sort_init "#{Rate.table_name}.date_in_effect", "desc"
|
||||
sort_update ['date_in_effect', 'project_id']
|
||||
sort_update ValidSortOptions
|
||||
|
||||
@rates = Rate.history_for_user(@user, sort_clause)
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ class Rate < ActiveRecord::Base
|
||||
named_scope :history_for_user, lambda { |user, order|
|
||||
{
|
||||
:conditions => { :user_id => user.id },
|
||||
:order => order
|
||||
:order => order,
|
||||
:include => :project
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<%# TODO: Refactor out of the view once there is a hook in the controller (Post 0.8.0). %>
|
||||
<%# Can't expect everyone to upgrade at the moment %>
|
||||
<% sort_init "#{Rate.table_name}.date_in_effect", "desc" %>
|
||||
<% sort_update ['date_in_effect', 'project_id'] %>
|
||||
<% sort_update RatesController::ValidSortOptions %>
|
||||
|
||||
<% @rates = Rate.history_for_user(@user, "#{Rate.table_name}.date_in_effect desc") %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user