Sha256: 8c08014264a2c51e930e14bb9f3be3344088b9127b8d0eab61b1038814ba3954
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
class ApplicationSearch # < ActiveRecord::Base def initialize(params, options = {}) @param_keyword = params[:keyword] @param_sort = params[:sort] @param_order = params[:order] @keyword = '%' + @param_keyword.to_s.gsub('%', '\%').gsub('_', '\_').strip + '%' @sort = 'id' @sort = @param_sort unless @param_sort.blank? @order = 'desc' @order = 'asc' if @param_order == 'asc' @tag_sort = @sort @tag_order = @order end attr_accessor :param_keyword attr_accessor :param_sort attr_accessor :param_order attr_accessor :form attr_accessor :keyword attr_accessor :orderby attr_accessor :tag_sort attr_accessor :tag_order #attr_accessor :sort def sort @sort end def sort=(val) @sort = val if val @orderby = @sort.to_s + ' ' + @order.to_s end #attr_accessor :order def order @order end def order=(val) @order = val if val @orderby = @sort.to_s + ' ' + @order.to_s end #attr_accessor :default_sort def default_sort @default_sort end def default_sort=(val) @default_sort = val if val @sort = @tag_sort = @default_sort if @param_sort.blank? end #attr_accessor :default_order def default_order @default_order end def default_order=(val) @default_order = val if val @order = @tag_order = @default_order if @param_order.blank? end def sort(val, val2) self.sort = val2 if val == @sort end def default(sort, order) self.default_sort = sort self.default_order = order end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ava_rails_generator-0.0.3 | templates/application_search.rb |
ava_rails_generator-0.0.2 | templates/application_search.rb |