我有一个rails应用程序,我在/app/adapters/UDB/
文件夹中有模块。模块未加载。我在application.rb
config.autoload_paths += Dir["#{config.root}/app/adapters/**/*"]
我从模型文件/models/userinvite.rb
def update_cassandra
ypusers = UDB::YpRewards.new.ypusers
ypusers.execute("UPDATE invitation_backlog SET invitation_code = '#{invitation_code}', invitation_sent_date = #{invitation_sent_date.to_i * 1000}, invited_by = '#{invited_by}' WHERE email_address = '#{email}'")
end
/app/adapters/UDB/yp_rewards.rb
module UDB
class YpRewards
def initialize
end
def ypusers
@ypusers ||= UDB::Connection.new.connection.connect('ypusers')
end
...
请帮我解决。
答案 0 :(得分:0)
我认为问题在于模块名称。
您的模块名称是UDB,然后您可以根据rails命名约定(camelcasing)以小写字母指定其名称来加载此模块
config.autoload_paths += %W( #{config.root}/app/adapters/u_d_b)
答案 1 :(得分:0)
尝试在UserInvite模型中包含该模块,
include UDB
This is a good site to know more about the placement and usage of modules.