Ruby Bharathrentals wrote:
> Hi I am trying to use ferret; the regular search works; but when I use
> the find_storage_by_contents to highlight the results, I am getting the
> above error. Please help
> thanks


I alse got this exception when i use the highlight function following 
the Acts_As_Ferret Tutorial on 
http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial

def find_storage_by_contents(query, options = {})
  index = self.ferret_index # Get the index that acts_as_ferret created 
for us
  results = []

  # search_each is the core search function from Ferret, which 
Acts_as_ferret hides
  total_hits = index.search_each(query, options) do |doc, score|
    result = {}

    # Store each field in a hash which we can reference in our views
    result[:name] = index.highlight(query, doc,
                    :field => :name,
                    :pre_tag => "<strong>",
                    :post_tag => "</strong>",
                    :num_excerpts => 1)
    result[:author_name] = index.highlight(query, doc,
                    :field => :author_name,
                    :pre_tag => "<strong>",
                    :post_tag => "</strong>",
                    :num_excerpts => 1)
    result[:score] = score   # We can even put the score in the hash, 
nice!

    results.push result
  end
  return block_given? ? total_hits : [total_hits, results]
end



index = self.ferret_index # Get the index that acts_as_ferret created 
for us
---------------------------------------------------------
this line of code get some error! undefined method `ferret_index'!!!
Need help!!!

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to