diff options
| -rw-r--r-- | app/controllers/lines_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/referential_lines_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/chouette/line.rb | 3 | 
3 files changed, 5 insertions, 2 deletions
| diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb index a93084012..bd1550a00 100644 --- a/app/controllers/lines_controller.rb +++ b/app/controllers/lines_controller.rb @@ -69,7 +69,7 @@ class LinesController < BreadcrumbController    end    def filtered_lines -    line_referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e }  } +    line_referential.lines.by_text(params[:q])    end    def collection diff --git a/app/controllers/referential_lines_controller.rb b/app/controllers/referential_lines_controller.rb index 165b4c262..05f80f718 100644 --- a/app/controllers/referential_lines_controller.rb +++ b/app/controllers/referential_lines_controller.rb @@ -63,7 +63,7 @@ class ReferentialLinesController < ChouetteController    end    def filtered_lines -    referential.lines.select{ |t| [t.name, t.published_name].find { |e| /#{params[:q]}/i =~ e }  } +    referential.lines.by_text(params[:q])    end    def collection diff --git a/app/models/chouette/line.rb b/app/models/chouette/line.rb index c3a867caa..76a421b4c 100644 --- a/app/models/chouette/line.rb +++ b/app/models/chouette/line.rb @@ -32,6 +32,9 @@ class Chouette::Line < Chouette::ActiveRecord    validates_presence_of :name +  scope :by_text, ->(text) { where('lower(name) LIKE :t or lower(published_name) LIKE :t or lower(objectid) LIKE :t or lower(comment) LIKE :t or lower(number) LIKE :t', +    t: "%#{text.downcase}%") } +    def self.nullable_attributes      [:published_name, :number, :comment, :url, :color, :text_color, :stable_id]    end | 
