Question: ```
#include<iostream>

void DFS(int);
int G[10][10], visited[10], n;

//G->Adjacency Matrix, n->no of vertices

void main()
{
int i,j;
cout<<"Enter vertices";
cin>>n
cout<<"Enter adjacency matrix";
for(i=0;i<n;i++)
    for(j=0;j<n;j++)
        cin>>G[j][i];

for(i=0;i<n;i++)
    visited[i]=0

DFS(0);

void DFS(int i)
{
int j;
cout<<"\n"<<i;
visited[i]=1;
for(j=0;j<n;j++)
    if(!visited[j] && G[i][j]==1)
            DFS(j);
}

```

What does the !visited[j] in the if condition mean? I understand that once you visit any node, you have to make the node bit in the array as 1, but how do we apply the not condition for any array?

Answer: 
I think in the database you are storing the query as String.While you are pulling it from database `@saved_search.query_parameters` is returning you the string.But the ransack needs it to be a Hash.This is the main problem I guess.

While you are passing through params its gets a Hash but from database its getting String.You need to parse the string you are getting from the `@query` variable and then pass it to the search.

For String to Hash conversion you can have a look at [How do I convert a String object into a Hash object?](https://stackoverflow.com/questions/1667630/how-do-i-convert-a-string-object-into-a-hash-object) question's answers.
Try this gem: <https://rubygems.org/gems/ransack_advanced_search>
is provides a nice interface for building queries and also allow you to name and store the search for later use. Is uses the serialize method from active\_record to save the query params from the database

```
class SavedSearch < ActiveRecord::Base
  validates_presence_of :context, :description, :search_params

  serialize :search_params
end

```

It will automatically convert the search\_params back to a hash when you read it from the database