lib/acts_as_data_table/shared/session.rb
#
# Adds a new filter to the current controller action
# Before the filter is added, the following things are checked to ensure
# that no invalid filter is added (which could cause reoccurring errors in the application)
#
#   1. The given +scope+ has to be registered in the currently used model
#   2. The given arguments have to be sufficient for the given +scope+
#   3. The +scope+ has to pass the set up validation check
#
# @param [String] group
#   The group the given +scope+ is part of in the current #model
#
# @param [String] scope
#   The scope name within +group+ and #model
#
# @param [Hash] args
#   Arguments to be passed to the scope. They have to be in the format
#   {arg_name => arg_value} as set up in the model. This is necessary
#   to make validations as easy as possible.
#
Adds a new filter to the current controller action
Before the filter is added, the following things are checked to ensure
that no invalid filter is added (which could cause reoccurring errors in the application)

1. The given +scope+ has to be registered in the currently used model
2. The given arguments have to be sufficient for the given +scope+
3. The +scope+ has to pass the set up validation check
Adds a new filter to the current controller action Before the filter is added the following things are checked to ensure that no invalid filter is added ( which could cause reoccurring errors in the application ) 1 . The given + scope + has to be registered in the currently used model 2 . The given arguments have to be sufficient for the given + scope + 3 . The + scope + has to pass the set up validation check
def add_filter(group, scope, args)
          reset_errors!
          args = {} unless args.is_a?(Hash)
          unless Acts::DataTable::ScopeFilters::ActiveRecord.registered_filter?(model, group, scope)
            add_error group, Acts::DataTable.t('scope_filters.add_filter.filter_not_registered', :model => model.name, :group => group, :scope_name => scope)
            return false
          end
          unless Acts::DataTable::ScopeFilters::ActiveRecord.matching_arity?(model, group, scope, args.size)
            add_error group, Acts::DataTable.t('scope_filters.add_filter.non_matching_arity', :model => model.name, :group => group, :scope_name => scope)
            return false
          end
          if (errors = Acts::DataTable::ScopeFilters::Validator.new(model, group, scope, args).validate).any?
            errors.each {|e| add_error(group, e)}
            return false
          end
          current_action_session[group.to_s] = {scope.to_s => args.stringify_keys}
          true
        end
def add_filter ( group , scope , args ) reset_errors! args = { } unless args . is_a? ( Hash ) unless Acts :: DataTable :: ScopeFilters :: ActiveRecord . registered_filter? ( model , group , scope ) add_error group , Acts :: DataTable . t ( 'scope_filters.add_filter.filter_not_registered' , :model => model . name , :group => group , :scope_name => scope ) return false end unless Acts :: DataTable :: ScopeFilters :: ActiveRecord . matching_arity? ( model , group , scope , args . size ) add_error group , Acts :: DataTable . t ( 'scope_filters.add_filter.non_matching_arity' , :model => model . name , :group => group , :scope_name => scope ) return false end if ( errors = Acts :: DataTable :: ScopeFilters :: Validator . new ( model , group , scope , args ) . validate ) . any? errors . each { | e | add_error ( group , e ) } return false end current_action_session [ group . to_s ] = { scope . to_s => args . stringify_keys } true end
Adds a new filter to the current controller action
Before the filter is added, the following things are checked to ensure
that no invalid filter is added (which could cause reoccurring errors in the application)
Adds a new filter to the current controller action Before the filter is added the following things are checked to ensure that no invalid filter is added ( which could cause reoccurring errors in the application )
#Ensure that the argument hash is set properly. The following methods #might fail for filters which do not require arguments otherwise. #Check whether the given filter was registered properly in the model #Check whether the given arguments are sufficient for the given filter #Run possible validation methods on the given filter and add generated error messages #Add the new filter to the session
group
scope
args
args Arguments to be passed to the scope. They have to be in the format {arg_name => arg_value} as set up in the model. This is necessary to make validations as easy as possible.
args Arguments to be passed to the scope . They have to be in the format { arg_name = > arg_value } as set up in the model . This is necessary to make validations as easy as possible .