Created
July 20, 2012 13:42
-
-
Save creich/3150777 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NameError (uninitialized constant SortHelperPatch::InstanceMethods::SortCriteria): | |
plugins/redmine_time_tracker/lib/sort_helper_patch.rb:15:in `sort_update_with_time_tracker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module SortHelper | |
class SortCriteria | |
def initialize | |
@criteria = [] | |
end | |
# <SOME OTHER METHODS> | |
end | |
def sort_update(criteria, sort_name=nil) | |
sort_name ||= self.sort_name | |
@sort_criteria = SortCriteria.new | |
@sort_criteria.available_criteria = criteria | |
@sort_criteria.from_param(params[:sort] || session[sort_name]) | |
@sort_criteria.criteria = @sort_default if @sort_criteria.empty? | |
session[sort_name] = @sort_criteria.to_param | |
end | |
# <SOME OTHER METHODS OUTSIDE OF THE CLASS> | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_dependency 'sort_helper' | |
module SortHelperPatch | |
def self.included(base) | |
base.send(:include, InstanceMethods) | |
base.class_eval do | |
alias_method_chain :sort_update, :time_tracker | |
end | |
end | |
module InstanceMethods | |
def sort_update_with_time_tracker(criteria, sort_name=nil) | |
sort_name ||= self.sort_name | |
@sort_criteria = SortCriteria.new | |
@sort_criteria.available_criteria = criteria | |
@sort_criteria.from_param(params[:sort] || session[sort_name]) | |
@sort_criteria.criteria = @sort_default if @sort_criteria.empty? | |
session[sort_name] = @sort_criteria.to_param | |
end | |
end | |
SortHelper.send(:include, SortHelperPatch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment