public
Description: Sort and search extension for spree.
Homepage:
Clone URL: git://github.com/edmundo/spree-search.git
commit  e666a4a77b6a32a6e461ce78b6ea7a843cfe880a
tree    e9148c03bb8ac32ab578719c166e3656a118955c
parent  07186759b799148f40992379fe5c12f888a3491f
spree-search / search_extension.rb
100644 39 lines (35 sloc) 1.39 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Uncomment this if you reference any of your controllers in activate
require_dependency 'application'
 
class SearchExtension < Spree::Extension
  version "0.99"
  description "Search and sort extension for spree."
  url "http://github.com/edmundo/spree-search/tree/master"
 
  def activate
    
# # Add pagination support for the find_by_sql method inside paginating_find plugin.
# PaginatingFind::ClassMethods.class_eval do
# def paginating_sql_find(count_query, query, options)
#
# # The current page defaults to 1 when not passed.
# options[:current] ||= "1"
#
# count_query = sanitize_sql(count_query)
# query = sanitize_sql(query)
#
# # execute the count query - need to know how many records we're looking at
# count = count_by_sql(count_query)
#
# PagingEnumerator.new(options[:page_size], count, false, options[:current], 1) do |page|
# # calculate the right offset values for current page and page_size
# offset = (options[:current].to_i - 1) * options[:page_size]
# limit = options[:page_size]
#
# # run the actual query - Note: do not include LIMIT statement in your query
# find_by_sql(query + " LIMIT #{offset},#{limit}")
# end
# end
# end
  end
  
  def self.require_gems(config)
    config.gem 'activerecord-tableless', :lib => 'tableless'
  end
end