我在其他线程中多次看到这个问题,但似乎没有一个答案适用。
环境:轨道3
来自 jugend 的亚马逊/ecs gem。唯一的文件在这里:http://github.com/jugend/amazon-ecs/blob/master/lib/amazon/ecs.rb http://github.com/jugend/amazon-ecs/blob/master/lib/amazon/ecs.rb
我的宝石文件有:
gem 'amazon-ecs', :git => 'git://github.com/jugend/amazon-ecs.git'
一切都在 irb 中进行。我可以跑:
捆绑控制台
需要“amazon/ecs”,然后前往城镇
当我尝试从控制器使用它时,如下所示:
需要“亚马逊/ECS”
require 'amazon/ecs'
class SearchController < ApplicationController
def index
end
def results
Amazon::Ecs.configure do |options|
options[:aWS_access_key_id] = '[key]'
options[:aWS_secret_key] = '[secret]'
end
res = Amazon::Ecs.item_search(params[:search], {:response_group => 'Medium', :search_index => 'All'})
end
end
我在第 8 行得到:未初始化的常量 SearchController::Amazon,我第一次尝试使用 Amazon。
ecs.rb 有一个 Amazon 模块,其中包含一个 Ecs 类。我不确定为什么这在 erb 中有效,而不是在 Rails 中有效。
我对 Rails 还很陌生,所以请用小词来回答。 :-/