Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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