2014-04-27 86 views
0

我有定義爲模型:軌道4混淆類模塊

class Phaxio 

require 'rest_client' 
require 'json' 

attr_accessor :api_key, :secret_key, :callback_url, :current_intranet 

def initialize(args) 
    @current_intranet = args.fetch(:current_intranet) 

    if Rails.env.production? 
     @api_key  = current_intranet.settings.find_first_by_group_type_name("phaxio","api_key").try(:value) 
     @secret_key = current_intranet.settings.find_first_by_group_type_name("phaxio","api_secret").try(:value) 
     @callback_url = "http://www.production.com/phaxio_holla_back" 
    else 
     @api_key  = current_intranet.settings.find_first_by_group_type_name("phaxio","api_key_test").try(:value) 
     @secret_key = current_intranet.settings.find_first_by_group_type_name("phaxio","api_secret_test").try(:value) 
     @callback_url = "http://development.com:3002/phaxio_holla_back" 
    end 
end 

沒有pha​​xio(或phaxios)表。該模型被命名爲「phaxio.rb」。我沒有pha​​xios_controller。

當我打電話給Phaxio.new(current_intranet)時,我得到了「Phaxio:Module」的「undefined method new」。我沒有Phaxio模塊,我已經在我的應用上做了一個grep(這很大),以確保「Phaxio」沒有在其他地方定義。任何想法我做錯了什麼?

不,該應用程序未命名爲「Phaxio」。我的application.rb中是:

require File.expand_path('../boot', __FILE__) 
require 'rails/all' 
Bundler.require(:default, Rails.env) 
module V2 
    class Application < Rails::Application 
     config.autoload_paths += Dir["#{config.root}/app/presenters/*"].find_all { |f| File.stat(f).directory? } 
     config.autoload_paths += Dir["#{config.root}/app/services/*"].find_all { |f| File.stat(f).directory? } 
     config.autoload_paths += Dir["#{config.root}/app/queries/*"].find_all { |f| File.stat(f).directory? } 
     config.autoload_paths += Dir["#{config.root}/lib/*"].find_all { |f| File.stat(f).directory? } 
     config.autoload_paths += %W(#{config.root}/lib) 

     $TECH_EMAIL  = ["[email protected]", "[email protected]"] 

     config.to_prepare do 
     Devise::SessionsController.layout "sessions" 
     #Devise::RegistrationsController.layout "sessions" 
     #Devise::ConfirmationsController.layout "sessions" 
     #Devise::UnlocksController.layout "sessions"    
     Devise::PasswordsController.layout "sessions" 
     end 
    end 
end 

require 'tools' 
require 'pdf_tools' 
+1

您的應用程序也有可能被命名爲「Phaxio」?什麼是你的配置/ application.rb? – cthulhu

+0

看到在rails控制檯中執行'Phaxio.inspect'會返回什麼會很有趣。 – igneus

回答

0

在從朋友不得已的建議,我改名的所有引用到phaxio到phaxio2,一切都很好。不知道爲什麼這有所作爲,因爲我已經運行grep來查找單詞「phaxio」的所有實例,以防有一些衝突的模塊,但沒有找到。我想有時候抓住吸管是行不通的!