0

我在 ruby​​ 中使用 Rest-client gem。我的代码如下..,

require 'rest_client'

puts RestClient.get 'http://localhost:3000/articles'

puts RestClient.put 'http://localhost:3000/', {:params => {:Bat => 'ball'}}

RestClient.post 'http://localhost:3000/articles', {:params => {:Name => 'list1', 'Content' => 'Article1'}}

我引用了在 rails 应用程序中运行的 URL,用户可以使用上面的 url 创建、删除、编辑、列出文章。对于 put、delete、post、get 方法,它会在我的提示中生成 URL 的 html 代码。但是它无法通过 ruby​​ 代码从列表中插入帖子/删除项目。在 RestClient 中可以吗?

4

1 回答 1

-1

我认为这里的问题是您需要进行身份验证。您可以使用 RestClient 做到这一点,但您需要链接您的调用。请参阅 rest_client 自述文件如何做到这一点。

于 2012-02-15T18:55:51.010 回答