gpt4 book ai didi

ruby-on-rails - Rails + bunny gem - 没有要加载的文件 - bunny

转载 作者:行者123 更新时间:2023-12-04 04:50:46 24 4
gpt4 key购买 nike

我有一个 rails Controller :

class Console::AccesorBillsController < ConsoleController
...
def bill
AcceccorBill.new.run

render :nothing => true
end
end

我在那里创建新模型并运行一个带有兔子页面示例的方法( http://rubybunny.info/articles/getting_started.html ):
require "bunny"

class AcceccorBill
def initialize()
end

def run
conn = Bunny.new
conn.start

ch = conn.create_channel
x = ch.fanout("nba.scores")

ch.queue("joe", :auto_delete => true).bind(x).subscribe do |delivery_info, metadata, payload|
puts "#{payload} => joe"
end

ch.queue("aaron", :auto_delete => true).bind(x).subscribe do |delivery_info, metadata, payload|
puts "#{payload} => aaron"
end

ch.queue("bob", :auto_delete => true).bind(x).subscribe do |delivery_info, metadata, payload|
puts "#{payload} => bob"
end

x.publish("BOS 101, NYK 89").publish("ORL 85, ALT 88")

conn.close
end
end

但我总是收到这个错误:
NameError - uninitialized constant AcceccorBill::Bunny:
(gem) activesupport-3.1.12/lib/active_support/dependencies.rb:507:in `load_missing_constant'
(gem) activesupport-3.1.12/lib/active_support/dependencies.rb:181:in `block in const_missing'
(gem) activesupport-3.1.12/lib/active_support/dependencies.rb:179:in `const_missing'
(gem) rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
app/ext/acceccor_bill.rb:6:in `initialize'
app/controllers/console/accesor_bills_controller.rb:17:in `bill'
(gem) actionpack-3.1.12/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
(gem) actionpack-3.1.12/lib/abstract_controller/base.rb:167:in `process_action'
(gem) actionpack-3.1.12/lib/action_controller/metal/rendering.rb:10:in `process_action'

有谁知道如何解决这个问题?

P.S.:我通过 bundler 安装了 gem,它看起来像 require不起作用。

最佳答案

解决了。

我忘了要求 bundler .所以我只是在文件的开头添加了这个:

require "bundler/setup"
require "bunny"

这就是全部。

关于ruby-on-rails - Rails + bunny gem - 没有要加载的文件 - bunny,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17469513/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com