У меня есть приложение Rails 5 и пользовательский модуль, хранящийся в lib/reusable.rb
.
module Reusable
def createCharge(amount, source, description, customer)
charge_params = {
amount: amount,
source: source,
description: description,
currency: 'usd'
}
return charge_params
end
end
Я добавил следующее к application.rb
:
config.autoload_paths << "#{Rails.root}/lib"
config.eager_load_paths << "#{Rails.root}/lib"
Когда я запускаю консоль, я могу запустить следующее:
2.3.4 :002 > include Reusable
=> Object
2.3.4 :003 > x = Reusable.createCharge(100, 1, "ffwefwef")
{
:amount => 100,
:source => 1,
:description => "ffwefwef",
:currency => "usd"
}
Но в моем контроллере я не могу сделать то же самое.Когда я пытаюсь сделать следующее:
class ChargesController < ApplicationController
before_action :authenticate_user!, only: [:new, :create]
before_action :set_client, only: [:new, :create]
before_action :set_order, only: [:create]
include Reusable
def create
charge_attempt = Reusable.createCharge(total, token, description, customer)
end
end
я получаю сообщение об ошибке:
NoMethodError (undefined method `createCharge' for Reusable:Module):
Есть идеи, почему не удается найти функцию?Я перезапустил свое приложение и напечатал Reusable.methods
на своей консоли, а функции там нет.