[英]Include a custom module on Spree and Rails
我正在嘗試將模塊添加到Spree上的class_eval
中。
該文件位於: lib/spree/core/app/models/spree/payment/processing.rb
嘗試了以下內容:
module Spree
Payment.class_eval do
require GatewayError
end
end
我試圖包括以下內容: lib/spree/error_override.rb
module Spree
module GatewayError
end
end
嘗試加載服務器時出現的錯誤是:
`block in <module:Spree>': uninitialized constant Spree::GatewayError (NameError)
如果有人可以向正確的方向指出我的想法,那是我第一次嘗試將自己的模塊包括在課程中。
先感謝您!
一種解決方案是在初始化過程中手動要求文件。
配置/初始化/ require.rb:
# put here all files that you want to require manually
require "#{Rails.root}/lib/spree/error_override.rb"
就是這樣-您的模塊現在可以使用了;)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.