识别url以从代码发送http命令

时间:2012-02-14 11:05:22

标签: ruby-on-rails ruby http http-request

我有一个奇怪的问题,我的项目有一个登录页面,这是有效的,但我必须使用这个登录页面使用http shell命令,如:

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的实例。评估时发生错误   为零。[]

1 个答案:

答案 0 :(得分:0)

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

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

我问自己你将如何处理这个问题,因为你不能用这种方法保持会话cookie?!