如何请求ActiveResource
我想在 Rails 中测试我的 RESTful 资源:
require 'rubygems'
require 'activeresource'
class Event < ActiveResource::Base
self.site = "http://localhost:3000"
end
events = Event.find(:all)
puts events.map(&:name)
我已经安装了 gem:
gem安装activeresource
但是当我启动代码时,我收到错误消息:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- activeresource (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from service.rb:2:in `<main>'
我如何需要 ActiveResource?
I want to test my RESTful resource in Rails:
require 'rubygems'
require 'activeresource'
class Event < ActiveResource::Base
self.site = "http://localhost:3000"
end
events = Event.find(:all)
puts events.map(&:name)
I have installed gem:
gem install activeresource
But when I launch my code I get the error message:
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- activeresource (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from service.rb:2:in `<main>'
How can I require ActiveResource?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的需求中有一个拼写错误,以下是正确的:
There is a typo in your require, the following is the correct one:
有了bunder,你就可以做到这一点,
通常gems需要名称等于gem名称的文件,用
gem“foo”:require =>; bar
语法您可以指定默认包含的不同文件。With bunder you can do this just with
Normally gems requires file with name equal to gem’s name, with
gem "foo" :require => bar
syntax you can specify different file to be included by default.我认为你可以这样做:
你还可以指定你想要的 activeresource 版本
例如, 。或者您可以完全省略这一行,但这样它会更干净......并且可以确保您获得正确的版本。
希望这有帮助,NoICE
i think you can do it this way:
You can also specify which version of activeresource you want by
for example. Or you can omit this line completely, but this way it's cleaner... and it makes sure that you get the right version.
Hope this helps, NoICE