Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7655099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:25:37+00:00 2026-05-31T12:25:37+00:00

Using: Rails 3.1.1 I am trying to create a search engine in my application

  • 0

Using: Rails 3.1.1

I am trying to create a search engine in my application that browses a large database (apprx 100 000 items) for string matches.

I am using the following:

fp = FeededProduct.where("name LIKE '%blue%'  OR description LIKE '%blue%'  OR category LIKE '%blue%'")

for the search query for “blue”.

When I run the equivalent search phrase in MySQL it works fine but when I try to run this in rails it shows:

NoMethodError: undefined method `fields' for nil:NilClass: SELECT `feeded_products`.* FROM `feeded_products`  WHERE (name LIKE '%blue%'  OR description LIKE '%blue%'  OR category LIKE '%blue%')

Clues and troubleshooting:

This happens only for large search results, I have not been able to distinguish a number but it crashes when it should have returned 920 results but it does NOT crash when returning 6 results!

My conclusion of the above is either that it cannot keep all the 920 results in the memory OR that there is some type of row that makes it crash and the more results, the more likely it is that it will contain that type of row. I am leaning more towards the first conclusion.

I cannot troubleshoot it very well because it crashes (with the same error code) when I try to run:

raise fp.inspect

It also crashes for:

fp.each do |prod| 
begin 
puts 'Do nothing'
rescue
puts 'Something crashed'
end

but it does NOT crash for:

raise fp.count.inspect 

So, am I having a memory type of problem? What can I do to trouble shoot this further and/or solve the problem?

Using: Mac OS X 10.7.2. Lion
Database: InnoDB
Adapter: Mysql2 (don’t know which version)

Stack:

ActiveRecord::StatementInvalid (NoMethodError: undefined method fields' for nil:NilClass: SELECT feeded_products`.* FROM feeded_products WHERE (name LIKE '%blue%' OR description LIKE '%blue%' OR category LIKE '%blue%')): app/controllers/search_results_controller.rb:190:in `show'

Edit 2012-03-06 Additional trouble shooting:

  • I tried with

    fp2 = FeededProduct.limit(60000)

to create a really big array of hits and it worked fine. So I guess that rules out my guess that the fp variable cannot hold a certain amount of items.

The core of the problem seems to be that if I use the:

fp = FeededProduct.where("name LIKE '%blue%'  OR description LIKE '%blue%'  OR category LIKE '%blue%'")

I cannot use the fp-variable for anything afterwards without the application crashing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:25:39+00:00Added an answer on May 31, 2026 at 12:25 pm

    I changed to mysql instead of mysql2 adapter and it solved the problem. Thanks everyone for trying! I learned a lot trouble shooting your suggestions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to program my first ajax interface using Rails. The application
I'm trying to make an API for my rails application using JSON responses to
I'm trying to display images using my web application written in Rails. I've come
Disclaimer: super new to rails. I'm using Rails 3.2 Anyways, I'm trying to create
I'm trying to create a Rails 3 validation that will ensure that people are
I'm trying to create thumbnails for uploaded images in a JRuby/Rails app using the
I'm trying to create a rails route for movies (on the root path) that
I'm using Rails 3 and ruby 1.9 I'm trying to create a customized URL
I am trying to create a photo viewer in Ruby on Rails using jquery-lightbox
Using Rails 3.0.9, I'm trying to redirect after a post to the create method

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.