Skip to content

Instantly share code, notes, and snippets.

@mlins
Created May 21, 2012 21:12
Show Gist options
  • Save mlins/2764759 to your computer and use it in GitHub Desktop.
Save mlins/2764759 to your computer and use it in GitHub Desktop.
Can I somehow access my property instance to build indexes dynamically?
class Property < ActiveRecord::Base
has_many :agents
searchable do
agents.each do |scoped_agent|
string "sort_agents_#{scoped_agent.id}" do
reordered_agents = agents.select { |agent| scoped_agent != agent }
reordered_agents << scoped_agent
reordered_agents.collect do |agent|
agents.last_name_first
end.join(' ').gsub(/,/, '')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment