Skip to content

Instantly share code, notes, and snippets.

@mallain
Created July 16, 2009 12:24
Show Gist options
  • Save mallain/148386 to your computer and use it in GitHub Desktop.
Save mallain/148386 to your computer and use it in GitHub Desktop.
UserProfile Model
xapit do |index|
index.text :first_name, :last_name
index.facet :diploma_skill
index.facet :trainings_translation_title
index.facet :first_name
index.facet :last_name
end
def trainings_translation_title
# Instanciation variables
array = Array.new
self.trainings.each do |x|
training_translations = TrainingTranslation.find_by_training_id(x.id)
array.push(training_translations.title)
end
return array
end
def diploma_skill
# Instanciation variables
array = Array.new
self.trainings.each do |x|
unless x.diploma_level_id.nil?
skill = SkillLevel.find(x.diploma_level_id)
# Recuperation des translations associes
skilltranslations = SkillLevelTranslation.find_by_skill_level_id(skill.id)
# Ajout dans le tableau
array.push(skilltranslations.name)
end
end
return array
end
<% @facets = UserProfile.search("*").facets%>
<% for facet in @facets %>
<%= facet.name %>
<% for option in facet.options %>
<%= link_to option.name, :overwrite_params => { :facets => option } %>
(<%= option.count %>)
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment