Commit b13acb431553bfea14046207b0be1c4d751afe98
1 parent
5954b097
Exists in
master
and in
28 other branches
Adding list of searchable items for models
Showing
11 changed files
with
58 additions
and
2 deletions
Show diff stats
app/controllers/application_controller.rb
| ... | ... | @@ -154,8 +154,8 @@ class ApplicationController < ActionController::Base |
| 154 | 154 | end |
| 155 | 155 | end |
| 156 | 156 | |
| 157 | - def find_by_contents(klass, query, paginate_options{}, options={}) | |
| 158 | - @plugins.first(:find_by_contents, klass, query, paginate_options, options) || | |
| 157 | + def find_by_contents(klass, query, paginate_options={}, options={}) | |
| 158 | + @plugins.first(:find_by_contents, klass, query, paginate_options, options)# || | |
| 159 | 159 | # Failback search using like |
| 160 | 160 | end |
| 161 | 161 | ... | ... |
app/models/article.rb
| ... | ... | @@ -2,6 +2,14 @@ require 'hpricot' |
| 2 | 2 | |
| 3 | 3 | class Article < ActiveRecord::Base |
| 4 | 4 | |
| 5 | + SEARCHABLE_FIELDS = { | |
| 6 | + :name => 10, | |
| 7 | + :abstract => 3, | |
| 8 | + :body => 2, | |
| 9 | + :slug => 1, | |
| 10 | + :filename => 1, | |
| 11 | + } | |
| 12 | + | |
| 5 | 13 | track_actions :create_article, :after_create, :keep_params => [:name, :url, :lead, :first_image], :if => Proc.new { |a| a.is_trackable? && !a.image? } |
| 6 | 14 | |
| 7 | 15 | # xss_terminate plugin can't sanitize array fields | ... | ... |
app/models/category.rb
| 1 | 1 | class Category < ActiveRecord::Base |
| 2 | 2 | |
| 3 | + SEARCHABLE_FIELDS = { | |
| 4 | + :name => 10, | |
| 5 | + :acronym => 5, | |
| 6 | + :abbreviation => 5, | |
| 7 | + :slug => 1, | |
| 8 | + } | |
| 9 | + | |
| 3 | 10 | validates_exclusion_of :slug, :in => [ 'index' ], :message => N_('%{fn} cannot be like that.').fix_i18n |
| 4 | 11 | validates_presence_of :name, :environment_id |
| 5 | 12 | validates_uniqueness_of :slug,:scope => [ :environment_id, :parent_id ], :message => N_('%{fn} is already being used by another category.').fix_i18n | ... | ... |
app/models/certifier.rb
app/models/comment.rb
app/models/license.rb
app/models/national_region.rb
app/models/product.rb
app/models/profile.rb
| ... | ... | @@ -3,6 +3,12 @@ |
| 3 | 3 | # which by default is the one returned by Environment:default. |
| 4 | 4 | class Profile < ActiveRecord::Base |
| 5 | 5 | |
| 6 | + SEARCHABLE_FIELDS = { | |
| 7 | + :name => 10, | |
| 8 | + :identifier => 5, | |
| 9 | + :nickname => 2, | |
| 10 | + } | |
| 11 | + | |
| 6 | 12 | module Roles |
| 7 | 13 | def self.admin(env_id) |
| 8 | 14 | find_role('admin', env_id) | ... | ... |
app/models/qualifier.rb