2012-02-14 41 views
0

我遇到一个奇怪的问题发送HTTP命令,我的项目有一个登录页面,这是工作,但我一直在使用像HTTP shell命令使用这个登录页面:indentify链接直接从代码

curl -v http://google.com/ 

我的问题是,我如何识别从源代码发送请求的URL? 按照源代码:

def create 
    if request.post? 
    if session[:account] = Account.authenticate(params[:account][:username], params[:account][:password]) 
     flash[:message] = "Login successful" 
     redirect_to :controller => "items", :action => "index" 
    else 
     flash[:notice] = "Login unsuccessful" 
     redirect_to :controller => "login", :action => "create" 
    end 
    end 
end 

如果我尝试发送这样的请求:

curl -d "account(username)=guilherme&account(password)=123456" http://localhost:3000/login 

我有这样的回应:

你有一个零对象时,你没有期待它!您可能需要 Array的实例。而评估 零出错。[]

回答

0

我真的不明白你的问题,但我认为您发布的卷曲线应使用,而不是括号

curl -d "account[username]=guilherme&account[password]=123456" http://localhost:3000/login 

我问自己括号你将如何处理这个问题,因为你不能使用这种方法保持session-cookies ?!

+0

我必须从Android应用程序发送请求到我的ruby应用程序,他们必须通过http请求将身份验证发送到我的登录页面,但是出现错误,不是真的错误,而是一个问题,何时我发送这个curl请求我没有得到认证令牌,只有cookie会话,你知道如何做到这一点吗? – guisantogui 2012-02-15 11:45:43