dubstep
September 8, 2011, 3:06pm
1
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 %>
EMP Name<%= @emp.name %>
in view error occurs as
“undefined method `id’ for nil:NilClass”
thanks,
-pab
Pab
September 8, 2011, 4:23pm
2
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
Pab
September 8, 2011, 5:07pm
3
hi,
it shows following error
NoMethodError (undefined method `each’ for #<ActsAsSolr::SearchResults:
0xaa0eb28>):
thanks,
-pab
Pab
September 8, 2011, 5:28pm
4
Pab
September 8, 2011, 5:17pm
5
On Thu, Sep 8, 2011 at 6:04 AM, Pab [email protected] wrote:
when i tried with search
---------------#ActsAsSolr::SearchResults:0x9a0f1dc
What did you find unclear about the doc for ActsAsSolr::SearchResults?
–
Hassan S. ------------------------ [email protected]
twitter: @hassan
Pab
September 9, 2011, 1:48pm
6
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.
Pab
September 9, 2011, 2:17pm
7
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
Pab
September 9, 2011, 8:30am
8
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 GitHub - mauricio/acts_as_solr: acts_as_solr active_record plugin to make your active_record models indexable using the Solr full text search tool plugin
wich results in following error "undefined method ‘find_by_solr’ for "
can any one provide me solution for this
thanks
-pab
Pab
September 9, 2011, 2:20pm
9
its searching for id where as i changed it as emp_id
is there any solution for this?