acts_as_solr problem ActsAsSolr::SearchResults:

hi,

     i am using acts_as_solr plugin when i tried with search    by    def search     puts "#####################"     # ids = params[:name]     @id = params[:query]     @emp = Employee.find_by_solr(@id)     puts "------------------------------#{@emp}"

    respond_to do |format|       format.html{render :action => 'search'}       format.xml     end   end

in my model i gave

acts_as_solr :fields => [ :name ]

when i tried with search

  puts "------------------------------#{@emp}" shows me the following

     ------------------------------#<ActsAsSolr::SearchResults: 0x9a0f1dc>

any one say me how to retrive value to view page

EMP id<%= @emp.id %><br> EMP Name<%= @emp.name %><br>

in view error occurs as "undefined method `id' for nil:NilClass"

thanks, -pab

As your example shows, when you do Employee.find_by_solr(@id) it does not return an Employee instance, but returns an instance of ActsAsSolr::SearchResults

You will need to iterate through the results:

results = Employee.find_by_solr(@id)

results.each do |emp|

puts emp.id

end

hi,

it shows following error

NoMethodError (undefined method `each' for #<ActsAsSolr::SearchResults: 0xaa0eb28>):

thanks, -pab

What did you find unclear about the doc for ActsAsSolr::SearchResults?

Looks like you might need to do results.results.each instead

Check the docs: http://code.paperplanes.de/acts_as_solr/rdoc/classes/ActsAsSolr/SearchResults.html

hi,

i am using https://github.com/mattmatt/acts_as_solr

which contains no "each" method in acts_as_solr/libs/ search_results.rb

so for me each is not working with ActsAsSolr::SearchResults

and i tried with https://github.com/mauricio/acts_as_solr plugin

wich results in following error "undefined method 'find_by_solr' for "

can any one provide me solution for this

thanks -pab

Did you check the documentation I linked to?

http://code.paperplanes.de/acts_as_solr/rdoc/classes/ActsAsSolr/SearchResults.html

Specifically, have a look at the records() results() or docs() methods.

hi,

   i got data using this three and i got another doubt in table i have changed id as emp_id, when i searched it it throws an error like

Mysql::Error: Unknown column 'employees.id' in 'where clause': SELECT `employees`.* FROM `employees` WHERE (employees.id in (NULL))

how can i over come this

thanks, -pab

its searching for id where as i changed it as emp_id is there any solution for this?