Hey Thank you very much for your reply.

I tried doing a curl as u said and i do get a 302 response


GET /accounts/search?name= HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4
OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:3000
> Accept: */*
>
< HTTP/1.1 302 Found
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: -1
< Location: http://localhost:3000/login?referer=/accounts/search?name=
< Content-Type: text/html; charset=utf-8
< X-Ua-Compatible: IE=Edge
< X-Request-Id: 53965c374ddaeab58ccb3bc1579058e6
< X-Runtime: 0.005424
< Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-06)
< Date: Thu, 07 Mar 2013 19:20:10 GMT
< Content-Length: 131
< Connection: Keep-Alive



Here is my controller code for search

# coding: UTF-8

class AccountsController < ApplicationController

  def search
    @accounts = []
    client = AccountsClient.new
    if params[:name]

      response = client.query_account(CGI.escape(params[:name]))
      if response.is_a?(Net::HTTPSuccess)
        account = JSON.parse(response.body)
        unless account.empty?
          session[:account] = account
          redirect_to account_path(params[:name])
        end
      end

        limit=100
        limit = params[:limit].to_i if
params[:limit].to_i.between?(1,100)


      offset = ''
      offset_param = params[:offset]
      if is_integer?(offset_param)
        offset = "&offset=#{params[:offset]}" if
offset_param.to_i.between?(0, 2**16)
        end

        query =
"?name=#{CGI.escape(params[:name])}&limit=#{limit}#{offset}"
        response = client.query_account(query)


      end
    end

  end

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to