Autocomplete metatags (#2063)

This commit is contained in:
Toks
2013-12-16 13:15:36 -05:00
parent 657606cb73
commit 5c04efce65
3 changed files with 222 additions and 33 deletions

View File

@@ -75,6 +75,10 @@ class TagSubscription < ActiveRecord::Base
where("creator_id = ?", user.id)
end
def name_matches(name)
where("lower(name) like ? escape E'\\\\'", name.to_escaped_for_sql_like)
end
def search(params)
q = scoped
params = {} if params.blank?
@@ -87,6 +91,10 @@ class TagSubscription < ActiveRecord::Base
q = q.where("creator_id = ?", CurrentUser.user.id)
end
if params[:name_matches]
q = q.name_matches(params[:name_matches].mb_chars.downcase.strip.tr(" ", "_"))
end
q = q.visible_to(CurrentUser.user)
q