Module: ActiveRecordExtension::ClassMethods
- Defined in:
- lib/active_record_extension.rb
Overview
add your static(class) methods here
Instance Method Summary collapse
- #name_or_title_or_code_or_barcode_starts_with(letter) ⇒ Object
- #starts_with_a ⇒ Object
- #starts_with_b ⇒ Object
- #starts_with_c ⇒ Object
- #starts_with_d ⇒ Object
- #starts_with_e ⇒ Object
- #starts_with_f ⇒ Object
- #starts_with_g ⇒ Object
- #starts_with_h ⇒ Object
- #starts_with_i ⇒ Object
- #starts_with_j ⇒ Object
- #starts_with_k ⇒ Object
- #starts_with_l ⇒ Object
- #starts_with_m ⇒ Object
- #starts_with_n ⇒ Object
- #starts_with_o ⇒ Object
- #starts_with_p ⇒ Object
- #starts_with_q ⇒ Object
- #starts_with_r ⇒ Object
- #starts_with_s ⇒ Object
- #starts_with_t ⇒ Object
- #starts_with_u ⇒ Object
- #starts_with_v ⇒ Object
- #starts_with_w ⇒ Object
- #starts_with_x ⇒ Object
- #starts_with_y ⇒ Object
- #starts_with_z ⇒ Object
-
#top_ten ⇒ Object
E.g: Order.top_ten.
Instance Method Details
#name_or_title_or_code_or_barcode_starts_with(letter) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/active_record_extension.rb', line 21 def 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 ⇒ Object
38 39 40 |
# File 'lib/active_record_extension.rb', line 38 def starts_with_a :a end |
#starts_with_b ⇒ Object
42 43 44 |
# File 'lib/active_record_extension.rb', line 42 def starts_with_b :b end |
#starts_with_c ⇒ Object
46 47 48 |
# File 'lib/active_record_extension.rb', line 46 def starts_with_c :c end |
#starts_with_d ⇒ Object
50 51 52 |
# File 'lib/active_record_extension.rb', line 50 def starts_with_d :d end |
#starts_with_e ⇒ Object
54 55 56 |
# File 'lib/active_record_extension.rb', line 54 def starts_with_e :e end |
#starts_with_f ⇒ Object
58 59 60 |
# File 'lib/active_record_extension.rb', line 58 def starts_with_f :f end |
#starts_with_g ⇒ Object
62 63 64 |
# File 'lib/active_record_extension.rb', line 62 def starts_with_g :g end |
#starts_with_h ⇒ Object
66 67 68 |
# File 'lib/active_record_extension.rb', line 66 def starts_with_h :h end |
#starts_with_i ⇒ Object
70 71 72 |
# File 'lib/active_record_extension.rb', line 70 def starts_with_i :i end |
#starts_with_j ⇒ Object
74 75 76 |
# File 'lib/active_record_extension.rb', line 74 def starts_with_j :j end |
#starts_with_k ⇒ Object
78 79 80 |
# File 'lib/active_record_extension.rb', line 78 def starts_with_k :k end |
#starts_with_l ⇒ Object
82 83 84 |
# File 'lib/active_record_extension.rb', line 82 def starts_with_l :l end |
#starts_with_m ⇒ Object
86 87 88 |
# File 'lib/active_record_extension.rb', line 86 def starts_with_m :m end |
#starts_with_n ⇒ Object
90 91 92 |
# File 'lib/active_record_extension.rb', line 90 def starts_with_n :n end |
#starts_with_o ⇒ Object
94 95 96 |
# File 'lib/active_record_extension.rb', line 94 def starts_with_o :o end |
#starts_with_p ⇒ Object
98 99 100 |
# File 'lib/active_record_extension.rb', line 98 def starts_with_p :p end |
#starts_with_q ⇒ Object
102 103 104 |
# File 'lib/active_record_extension.rb', line 102 def starts_with_q :q end |
#starts_with_r ⇒ Object
106 107 108 |
# File 'lib/active_record_extension.rb', line 106 def starts_with_r :r end |
#starts_with_s ⇒ Object
110 111 112 |
# File 'lib/active_record_extension.rb', line 110 def starts_with_s :s end |
#starts_with_t ⇒ Object
114 115 116 |
# File 'lib/active_record_extension.rb', line 114 def starts_with_t :t end |
#starts_with_u ⇒ Object
118 119 120 |
# File 'lib/active_record_extension.rb', line 118 def starts_with_u :u end |
#starts_with_v ⇒ Object
122 123 124 |
# File 'lib/active_record_extension.rb', line 122 def starts_with_v :v end |
#starts_with_w ⇒ Object
126 127 128 |
# File 'lib/active_record_extension.rb', line 126 def starts_with_w :w end |
#starts_with_x ⇒ Object
130 131 132 |
# File 'lib/active_record_extension.rb', line 130 def starts_with_x :x end |
#starts_with_y ⇒ Object
134 135 136 |
# File 'lib/active_record_extension.rb', line 134 def starts_with_y :y end |
#starts_with_z ⇒ Object
138 139 140 |
# File 'lib/active_record_extension.rb', line 138 def starts_with_z :z end |
#top_ten ⇒ Object
E.g: Order.top_ten
17 18 19 |
# File 'lib/active_record_extension.rb', line 17 def top_ten limit(10) end |