I am trying to add advanced search facilities to a Blacklight installation, but I know slim to nil about rails.
I am stuck in a (so far great) tutorial that states:
Turn this feature on by adding to your CatalogController definition:
self.search_params_logic << :add_advanced_parse_q_to_solr
I can find my CatalogController, but I have no clue where to put the "<< :add_advanced_parse_q_to_solr" thingie.
Is it a part of the class definition in the top? As it is now it says:
class CataligController < ApplicationController
Am I supposed to exchange the "< ApplicationController" with "<< :add_advanced_parse_q_to_solr", or should I just append it?
What does the ":" mean, and what does the "<<" mean?
If anyone have any good references to tutorials that can teach me these (I guess) basic syntaxes, please post them here - I would love to understand what I am doing instead of just copy/pasting me my way through!
The added line should appear within your
CatalogControllerdefinition, so...The
<operation shows class inheritance in the first line. The<<operation means add the value on the right as a new element to the array on the left. An equivalent way would be to use the array push method...self.search_params_logic.push(:add_advanced_parse_q_to_solr)
Which brings us to the question about what
.means... it simply means you're calling a method that is part of an object or object's class.For example
Strings have a method downcase, and in the above line you're calling that method on the string and the result will be returned.
self.search_params_logicmeans you're calling a method onself(in this case,selfis theCatalogControllerso you could have also doneCatalogController.search_params_logicbut it's not very elegant).The
search_params_logicreturns an array and you can manipulate the array... add or remove elements, for example.