代码之家  ›  专栏  ›  技术社区  ›  Daniel Papasian

如何访问使用Ramaze框架放置数据?

  •  2
  • Daniel Papasian  · 技术社区  · 15 年前

    我正试图使用Ruby框架Ramaze来实现一个RESTful控制器。然而,当我发送Put时,似乎无法访问请求中的数据。样例代码:

    require 'ramaze'
    
    class PutController < Ramaze::Controller
     map '/'
    
     def index
        "Argument of "+request[:id]
     end
    end
    
    Ramaze.start
    

    我通过旋度与之互动:

    % curl -d id=5 "http://localhost:7000/"
    Argument of 5
    
    % curl -v -X PUT -d id=5 "http://localhost:7000/" > /dev/null
    ...
    HTTP/1.1 500 Internal Server Error
    [With a backtrace revealing that the request object is nil]
    

    我做错什么了吗?我该如何处理《斋戒》中提出的请求?

    1 回复  |  直到 15 年前
        1
  •  3
  •   george haff    15 年前

    试试这个:

    require 'rubygems'
    require 'ramaze'
    
    class PutController < Ramaze::Controller
     map '/'
    
     def index
        "Argument of "+request.POST['id']
     end
    end
    
    Ramaze.start
    

    它既适用于Put,也适用于Post和GeT。

    推荐文章