title: difficulty in moving around code in rails
body: <p>I have the following code in the controller</p>
  
  <pre><code>def search 
  
  if params[:name]
        response = client.get_games(params[:name])
        if response.is_a?(Net::HTTPSuccess)
          games = client.parser(response)
          unless games.empty?
            session[:games] = games
            redirect_to game_path(params[:name])
          end
        end
  ....
  ....
  ....
  end
  end
  I have the following code written in my client
  
  def get_games(name)
      find_games(CGI.escape(name))
   end
  </code></pre>
  
  <p>I am finding difficulties in moving some of the logic to the get_games method in my client. For example doing this does not work for me and i would like some suggestions on how i could go about or if i am doing things wrong</p>
  
  <pre><code>if params[:name]
    games = client.get_games(params[:name])
    unless games.empty?
      session[:games] = games
            redirect_to game_path(params[:name])
          end
        end
  ...
  ...
  ...
  end
  end
  
  def get_games(name)
  response = find_games(CGI.escape(name))
  if response.is_a?(NET::HTTPSuccess)
  return JSON.parse(response.body)
  else 
  return nil
  end
  end
  </code></pre>
  
  <p>The former case works but the latter does not work.Basically i just need help in moving the code inside the <code>def search</code> to client and have only the <code>redirect_to game_path(params[:name])</code> in my controller. Any help much appreciated</p>