module AppFrame::ControllerMethods::SearchSupport

Public Instance Methods

end_of_association_chain() click to toggle source
Calls superclass method
# File lib/app_frame/controller_methods.rb, line 48
def end_of_association_chain
  chain = super

  return chain if chain.is_a?(ActiveRecord::Base) #|| chain.is_a?(Array)
    
  chain = chain.with_query(params[:q]) if params[:q].present? && searchable?
    
  if params[:tags].present?
    tag_options = {}
    tag_options[:any] = true if params[:match] == 'any'
    chain = chain.tagged_with(params[:tags], tag_options) 
  end
    
  chain = chain.send(list_scope) if resource_class.respond_to?(list_scope)
    
  chain
end
list_scope() click to toggle source
# File lib/app_frame/controller_methods.rb, line 44
def list_scope
  @list_scope ||= (controller_namespaces.map(&:to_s).join("_") + "_list").to_sym
end
searchable?() click to toggle source
# File lib/app_frame/controller_methods.rb, line 40
def searchable?
  resource_class.respond_to?(:with_query)
end