Created
June 9, 2013 20:57
-
-
Save bplexico/5745179 to your computer and use it in GitHub Desktop.
new methods in each object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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