Rails Query Strings


These past few days I've been working on a project for DevBootCamp which required me to search for similar Objects by columns. After banging my head for awhile, trying to use one-to-one relationships and polymorphic pathing, my friend Gunnari gave me a lightbulb. Why not use query strings? And so here is the view and corresponding controller for query strings in Rails 4.

In the view, we set the key as :query and in the controller I use a case statement for the key on line 3.