Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search gives 500 Internal Error with ArgumentError from search_controller.rb #57

Open
thchung opened this issue Aug 29, 2013 · 6 comments
Labels

Comments

@thchung
Copy link

thchung commented Aug 29, 2013

When entering search in the Redmine search box (under "All Projects" or while leaving the default "Jump to a project..." in the dropdown box), occasionally will get the Redmine 500 error.

However, it isn't consistent, and seems to fail (repeatably) on certain words/phrases. For example, search for "Ground Robots" correctly returns a number of valid entries, but search for "Ground Robot" returns the 500 error and the following production.log message:

Started GET "/redmine/public/search?utf8=%E2%9C%93&q=Ground+Robot&scope=all&all_words=&all_words=1&titles_only=&issues=1&news=1&documents=1&changesets=1&wiki_pages=1&messages=1&projects=1&equipment_assets=1&submit=Submit" for xxx.xxx.xxx.xxx at 2013-08-28 17:47:08 -0700
Processing by SearchController#index as HTML
  Parameters: {"utf8"=>"✓", "q"=>"Ground Robot", "scope"=>"all", "all_words"=>"1", "titles_only"=>"", "issues"=>"1", "news"=>"1", "documents"=>"1", "changesets"=>"1", "wiki_pages"=>"1", "messages"=>"1", "projects"=>"1", "equipment_assets"=>"1", "submit"=>"Submit"}
  Current user: thchung (id=5)
Completed 500 Internal Server Error in 94ms

ArgumentError (comparison of WikiPage with EquipmentAsset failed):
  app/controllers/search_controller.rb:83:in `sort'
  app/controllers/search_controller.rb:83:in `index'

Other search queries seem to elicit variations on this error, namely

ArgumentError (comparison of EquipmentAsset with EquipmentAsset failed):

or

ArgumentError (comparison of Issue with EquipmentAsset failed):

All three variations reference Line 83 in /app/controllers/search_controller.rb, but I'm new to Ruby/Rails and don't know why there's an error here.

With a large inventory list, having this robust (or at least reliable) search capability is a must! Thanks in advance!

@sukima
Copy link
Owner

sukima commented Aug 29, 2013

Searching has always been a problem for me. It works really weird in Redmine. When I was active on this project trying to fix this was a low priority. I no longer actively work on this instead relying on pull requests. As a contributing member of a local ruby group and mentor to others learning ruby, I'd highly recommend using this as a learner's project or motivation to keep learning ruby! I would be happy to chat about it and maybe get you contributing a pull request or start of one. More for your experience and credit than anything else.

For now I'll log this as a bug to take a look at if I do end up looking into this project again.

@sukima
Copy link
Owner

sukima commented Aug 29, 2013

Looking at the error I'm guessing that the search_controller uses a specific method to compare models. I'm betting that the EquipmentAsset model does not conform to that specification. I'd have to look at the Redmine source to figure out what that specification should be.

@thchung
Copy link
Author

thchung commented Dec 30, 2013

Thanks for the guidance. A further investigation looking at Line 83 seems to hint (as referenced above) that the sort command might be causing the problems. Looking at the database structures created for equipment_assets (in particular, in datatable for assets_check_in), the record appears to be named created_at, whereas many of the other examples refer to a created_on field.

Could this be the source of a mis-matched ordering? Or perhaps something even deeper, since the lack of search functionality appears to work for some search words but not others? Any other thoughts?

@sukima
Copy link
Owner

sukima commented Jan 2, 2014

This is very possible. A bit of research shows that in an ActiveRecord model created_at is a datetime stamp and created_on is just a date stamp. However, I believe the internal database column name is created_at. If a sort is trying to reference a database column name and not the rails model then it needs to match the column name (created_at) as far as I know.

Would you be willing to test this? Can you offer a Pull Request?

@sukima
Copy link
Owner

sukima commented Jan 2, 2014

In thinking I wrote this back in the day when I had no idea how to write rails let alone ruby so I'm sure there are a lot of opps going on. I would never recommend this code be a good example.

@thchung
Copy link
Author

thchung commented Jan 28, 2014

Hi Devin,

I'll play around and see what I can do when I have some free time, but unfortunately (as you can see by how long it took for me to get back to this), it may be some time before I get a chance to dig back into things.

Thanks for your feedback and offer to help.
Blue skies,
-Tim

Timothy H. Chung, Ph.D.
Assistant Professor
Systems Engineering Department
Naval Postgraduate School
Monterey, CA 93943
http://faculty.nps.edu/thchung
+1 831 656 7858 (o)
+1 831 656 1922 (lab)
thchung@nps.edu
chungth@nps.navy.smil.mil

On 1/2/14 7:15 AM, "Devin Weaver" <notifications@github.commailto:notifications@github.com> wrote:

This is very possible. A bit of research shows that in an ActiveRecord model created_at is a datetime stamp and created_on is just a date stamp. However, I believe the internal database column name is created_at. If a sort is trying to reference a database column name and not the rails model then it needs to match the column name (created_at) as far as I know.

Would you be willing to test this? Can you offer a Pull Request?


Reply to this email directly or view it on GitHubhttps://github.com//issues/57#issuecomment-31458464.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants