Skip to content

Instantly share code, notes, and snippets.

@bplexico
Created June 9, 2013 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bplexico/5745179 to your computer and use it in GitHub Desktop.
Save bplexico/5745179 to your computer and use it in GitHub Desktop.
new methods in each object
#USER//////////////////////////////////////
def update_search_data_index
if username_changed? || name_changed?
search_data = username.dup << " " << (name || "")
ObserverSearchData.new(self, search_data).update_index
end
end
#TOPIC//////////////////////////////////////
def update_search_data_index
if title_changed? && posts
post = posts.where(post_number: 1).first
if post
search_data = post.scrubbed_html << " " << title
search_data << " " << category.name if category
ObserverSearchData.new(post, search_data).update_index
end
end
end
#CATEGORY//////////////////////////////////////
def update_search_data_index
ObserverSearchData.new(self, name).update_index if name_changed?
end
#POST//////////////////////////////////////
def update_search_data_index
if cooked_changed?
search_data = scrubbed_html << " " << topic.title
search_data << " " << topic.category.name if topic.category
ObserverSearchData.new(self, search_data).update_index
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment