module ActiveRecordExtension::ClassMethods

add your static(class) methods here

Public Instance Methods

name_or_title_or_code_or_barcode_starts_with(letter) click to toggle source
# File lib/active_record_extension.rb, line 21
def name_or_title_or_code_or_barcode_starts_with letter
  # Se ha name o code o barcode, uso uno di questi:
  column = if self.column_names.include? "name"
    :name
  elsif self.column_names.include? "title"
    :title
  elsif self.column_names.include? "code"
    :code
  elsif self.column_names.include? "barcode"
    :barcode
  end
  # Ecco la ricerca dedicata a Postgres, la facciamo multiplatform? Fatto
  query = "#{letter}%"
  match = arel_table[column].matches(query)
  where(match)
end
starts_with_a() click to toggle source
# File lib/active_record_extension.rb, line 38
def starts_with_a
  name_or_title_or_code_or_barcode_starts_with :a
end
starts_with_b() click to toggle source
# File lib/active_record_extension.rb, line 42
def starts_with_b
  name_or_title_or_code_or_barcode_starts_with :b
end
starts_with_c() click to toggle source
# File lib/active_record_extension.rb, line 46
def starts_with_c
  name_or_title_or_code_or_barcode_starts_with :c
end
starts_with_d() click to toggle source
# File lib/active_record_extension.rb, line 50
def starts_with_d
  name_or_title_or_code_or_barcode_starts_with :d
end
starts_with_e() click to toggle source
# File lib/active_record_extension.rb, line 54
def starts_with_e
  name_or_title_or_code_or_barcode_starts_with :e
end
starts_with_f() click to toggle source
# File lib/active_record_extension.rb, line 58
def starts_with_f
  name_or_title_or_code_or_barcode_starts_with :f
end
starts_with_g() click to toggle source
# File lib/active_record_extension.rb, line 62
def starts_with_g
  name_or_title_or_code_or_barcode_starts_with :g
end
starts_with_h() click to toggle source
# File lib/active_record_extension.rb, line 66
def starts_with_h
  name_or_title_or_code_or_barcode_starts_with :h
end
starts_with_i() click to toggle source
# File lib/active_record_extension.rb, line 70
def starts_with_i
  name_or_title_or_code_or_barcode_starts_with :i
end
starts_with_j() click to toggle source
# File lib/active_record_extension.rb, line 74
def starts_with_j
  name_or_title_or_code_or_barcode_starts_with :j
end
starts_with_k() click to toggle source
# File lib/active_record_extension.rb, line 78
def starts_with_k
  name_or_title_or_code_or_barcode_starts_with :k
end
starts_with_l() click to toggle source
# File lib/active_record_extension.rb, line 82
def starts_with_l
  name_or_title_or_code_or_barcode_starts_with :l
end
starts_with_m() click to toggle source
# File lib/active_record_extension.rb, line 86
def starts_with_m
  name_or_title_or_code_or_barcode_starts_with :m
end
starts_with_n() click to toggle source
# File lib/active_record_extension.rb, line 90
def starts_with_n
  name_or_title_or_code_or_barcode_starts_with :n
end
starts_with_o() click to toggle source
# File lib/active_record_extension.rb, line 94
def starts_with_o
  name_or_title_or_code_or_barcode_starts_with :o
end
starts_with_p() click to toggle source
# File lib/active_record_extension.rb, line 98
def starts_with_p
  name_or_title_or_code_or_barcode_starts_with :p
end
starts_with_q() click to toggle source
# File lib/active_record_extension.rb, line 102
def starts_with_q
  name_or_title_or_code_or_barcode_starts_with :q
end
starts_with_r() click to toggle source
# File lib/active_record_extension.rb, line 106
def starts_with_r
  name_or_title_or_code_or_barcode_starts_with :r
end
starts_with_s() click to toggle source
# File lib/active_record_extension.rb, line 110
def starts_with_s
  name_or_title_or_code_or_barcode_starts_with :s
end
starts_with_t() click to toggle source
# File lib/active_record_extension.rb, line 114
def starts_with_t
  name_or_title_or_code_or_barcode_starts_with :t
end
starts_with_u() click to toggle source
# File lib/active_record_extension.rb, line 118
def starts_with_u
  name_or_title_or_code_or_barcode_starts_with :u
end
starts_with_v() click to toggle source
# File lib/active_record_extension.rb, line 122
def starts_with_v
  name_or_title_or_code_or_barcode_starts_with :v
end
starts_with_w() click to toggle source
# File lib/active_record_extension.rb, line 126
def starts_with_w
  name_or_title_or_code_or_barcode_starts_with :w
end
starts_with_x() click to toggle source
# File lib/active_record_extension.rb, line 130
def starts_with_x
  name_or_title_or_code_or_barcode_starts_with :x
end
starts_with_y() click to toggle source
# File lib/active_record_extension.rb, line 134
def starts_with_y
  name_or_title_or_code_or_barcode_starts_with :y
end
starts_with_z() click to toggle source
# File lib/active_record_extension.rb, line 138
def starts_with_z
  name_or_title_or_code_or_barcode_starts_with :z
end
top_ten() click to toggle source

E.g: Order.top_ten

# File lib/active_record_extension.rb, line 17
def top_ten
  limit(10)
end