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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/ga8jz_qer4UJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
hi, it shows following error NoMethodError (undefined method `each'' for #<ActsAsSolr::SearchResults: 0xaa0eb28>): thanks, -pab -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hassan Schroeder
2011-Sep-08 15:15 UTC
Re: acts_as_solr problem ActsAsSolr::SearchResults:
On Thu, Sep 8, 2011 at 6:04 AM, Pab <prabu.net88-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> when i tried with search> ---------------#<ActsAsSolr::SearchResults:0x9a0f1dc>What did you find unclear about the doc for ActsAsSolr::SearchResults? -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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<http://code.paperplanes.de/acts_as_solr/rdoc/classes/ActsAsSolr/SearchResults.html#M000032> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/_vrcvL294JkJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/6gNwPvP3gI8J. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
its searching for id where as i changed it as emp_id is there any solution for this? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.