Welcome Guest | Login

LoadError (Expected ../config/../app/models/charge.rb to define Charge):

Good Evening!

I am in the process of trying out my newly deployed site.  Everything seemed to be going smoothly until I ran into the error in the subject line.
I have tried killall -usr1 dispatch.fcgi as well as rake rails:freeze:gems
I greatly appreciate any little nudges you may have to offer!
:)
Jee
###############  production.log ###################################

Processing CheckoutController#get_creditcard_information (for xx.x.xxx.xx at 2007-07-20 21:33:04) [POST]
 Session ID: 49417a66be8d88b862209e0d932ca518
 Parameters: {"commit"=>"[complete order]", "action"=>"get_creditcard_information", "controller"=>"checkout"}


LoadError (Expected ../config/../app/models/charge.rb to define Charge):
   /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:249:in `load_missing_constant'
   /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:452:in `const_missing'
   /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:464:in `const_missing'
   /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:260:in `load_missing_constant'
   /vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:468:in `const_missing'
   /vendor/rails/activerecord/lib/active_record/base.rb:1360:in `compute_type'
   /vendor/rails/activerecord/lib/active_record/reflection.rb:125:in `send'
   /vendor/rails/activerecord/lib/active_record/reflection.rb:125:in `klass'
   /vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:158:in `construct_sql'
   /vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb:6:in `initialize'
   /vendor/rails/activerecord/lib/active_record/associations.rb:934:in `new'
   /vendor/rails/activerecord/lib/active_record/associations.rb:934:in `charges'
   (eval):3:in `destroy_without_callbacks'
   /vendor/rails/activerecord/lib/active_record/callbacks.rb:321:in `destroy_without_transactions'
   /vendor/rails/activerecord/lib/active_record/transactions.rb:125:in `destroy'
   /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in `transaction'
   /vendor/rails/activerecord/lib/active_record/transactions.rb:95:in `transaction'
   /vendor/rails/activerecord/lib/active_record/transactions.rb:121:in `transaction'
   /vendor/rails/activerecord/lib/active_record/transactions.rb:125:in `destroy'
   /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:82:in `destroy_all'
   /vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `each'
   /vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `send'
   /vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:123:in `method_missing'
   /vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb:98:in `method_missing'
   /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:82:in `destroy_all'
   /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:59:in `transaction'
   /vendor/rails/activerecord/lib/active_record/transactions.rb:95:in `transaction'
   /vendor/rails/activerecord/lib/active_record/transactions.rb:121:in `transaction'
   /vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:81:in `destroy_all'
   /app/controllers/checkout_controller.rb:98:in `clear_items'
   /app/controllers/checkout_controller.rb:74:in `populate_items'
   /app/controllers/checkout_controller.rb:68:in `get_creditcard_information'
   /vendor/rails/actionpack/lib/action_controller/base.rb:1095:in `send'
   /vendor/rails/actionpack/lib/action_controller/base.rb:1095:in `perform_action_without_filters'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:632:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:638:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:438:in `call'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:637:in `call_filter'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:619:in `perform_action_without_benchmark'
   /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
   /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
   /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:66:in `perform_action_without_rescue'
   /vendor/rails/actionpack/lib/action_controller/rescue.rb:83:in `perform_action'
   /vendor/rails/actionpack/lib/action_controller/base.rb:430:in `send'
   /vendor/rails/actionpack/lib/action_controller/base.rb:430:in `process_without_filters'
   /vendor/rails/actionpack/lib/action_controller/filters.rb:624:in `process_without_session_management_support'
   /vendor/rails/actionpack/lib/action_controller/session_management.rb:114:in `process'
   /vendor/rails/actionpack/lib/action_controller/base.rb:330:in `process'
   /vendor/rails/railties/lib/dispatcher.rb:41:in `dispatch'
   /vendor/rails/railties/lib/fcgi_handler.rb:168:in `process_request'
   /vendor/rails/railties/lib/fcgi_handler.rb:143:in `process_each_request!'
   /vendor/rails/railties/lib/fcgi_handler.rb:109:in `with_signal_handler'
   /vendor/rails/railties/lib/fcgi_handler.rb:142:in `process_each_request!'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:612:in `each_cgi'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each'
   /usr/local/lib/ruby/gems/1.8/gems/fcgi-0.8.7/lib/fcgi.rb:609:in `each_cgi'
   /vendor/rails/railties/lib/fcgi_handler.rb:141:in `process_each_request!'
   /vendor/rails/railties/lib/fcgi_handler.rb:55:in `process!'
   /vendor/rails/railties/lib/fcgi_handler.rb:25:in `process!'
   dispatch.fcgi:24


2007-07-20 09:44 PM

Life is too short for this ...
Hi there - check the syntax of app/models/charge.rb -- what are the first 5 lines or so of that file?  I'm assuming this is, however, working locally for you?  

2007-07-20 11:53 PM

William,

Yes, this has been working fine locally.  Could it have to do with the relative path to the pem file?
Thanks!

##############  charge.rb#################
ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../1001115414.pem'  )
require 'JurisLookupDriver.rb'

class Charge < ActiveRecord::Base
 
 #Additional Config
 include ActiveMerchant::Billing
 
 #Administrative for shipping api
   require 'uri'
   require 'net/http'
   require "rexml/document"
   include REXML

2007-07-21 07:56 AM

Life is too short for this ...
no - make sure that "class Charge < ActiveRecord::Base" is the first line of the file and it should work.  Just put the other lines below it or in your environment.rb file.  I think this is what is throwing the error.  

2007-07-21 10:05 AM

Hi again,
I tried changing the first few lines of charge.rb to the following which gave me an application error.  Then I tried moving the offending lines to the environment.rb file with the same results.  I did try to change the paths appropriately.  See the bottom code snippet.

########################          charge.rb
class Charge < ActiveRecord::Base
ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../**********.pem'  )
require 'JurisLookupDriver.rb'


###################           environment.rb
ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + 'app/**********.pem'  )
require 'app/models/JurisLookupDriver.rb'


Any other suggestiosns?
Jee

2007-07-23 12:49 PM

Life is too short for this ...
Jee, actually I came across this error on one of my own apps yesterday.  Turns out this is an extremely common problem.  For me, it was because there was a missing plugin because of a botched SVN check out.  However, as you'll read in that ticket the only real answers are either to find and hack the culprit gem/plugin or switch off model caching. I would suggest hunting down the problem in your case because the ladder will slow down your app.  

2007-07-23 05:45 PM

Hello again,

I am pretty sure my issue lies in the following code.  Uncommenting
require 'rubygems'
gem 'soap4r'
FINALLY creates a different error in production.log

Gem::LoadError (Could not find RubyGem soap4r (>= 0.0.0)

For general info: This code was generated from WSDL following the instructions at http://www.brendonwilson.com/blog/2006/04/02/ruby-soap4r-wsdl-hell/

Can you please take a look and give me some hints?  :)

Thanks,
Jee

####################  Original Code  ################################################
require 'JurisLookup.rb'
#require 'rubygems'
#gem 'soap4r'
require 'soap/mapping'

module JurisLookupMappingRegistry

 EncodedRegistry = ::SOAP::Mapping::EncodedRegistry.new
 LiteralRegistry = ::SOAP::Mapping::LiteralRegistry.new

 EncodedRegistry.register(
   :class => TLookUpResults,
   :schema_ns => "urn:JurisLookup",
   :schema_type => "TLookUpResults",
   :schema_element => [
     ["intReturnCode", ["SOAP::SOAPInt", XSD::QName.new(nil, "intReturnCode")]],
     ["strReturnShortDesc", ["SOAP::SOAPString", XSD::QName.new(nil, "strReturnShortDesc")]],
     ["strConfirmationNum", ["SOAP::SOAPString", XSD::QName.new(nil, "strConfirmationNum")]],
     ["strEventTimeStamp", ["SOAP::SOAPString", XSD::QName.new(nil, "strEventTimeStamp")]],
     ["fIPSRecordList", ["TArrayofFIPSRecord", XSD::QName.new(nil, "FIPSRecordList")]]
   ]
 )

 EncodedRegistry.set(
   TArrayofFIPSRecord,
   ::SOAP::SOAPArray,
   ::SOAP::Mapping::EncodedRegistry::TypedArrayFactory,
   { :type => XSD::QName.new("urn:JurisLookup", "TFIPSRecord") }
 )

 EncodedRegistry.register(
   :class => TFIPSRecord,
   :schema_ns => "urn:JurisLookup",
   :schema_type => "TFIPSRecord",
   :schema_element => [
     ["intState", ["SOAP::SOAPInt", XSD::QName.new(nil, "intState")]],
     ["strJurisdictionType", ["SOAP::SOAPString", XSD::QName.new(nil, "strJurisdictionType")]],
     ["strCompositeSER", ["SOAP::SOAPString", XSD::QName.new(nil, "strCompositeSER")]],
     ["intJurisdictionFIPS", ["SOAP::SOAPInt", XSD::QName.new(nil, "intJurisdictionFIPS")]],
     ["strGeneralTaxRateIntrastate", ["SOAP::SOAPString", XSD::QName.new(nil, "strGeneralTaxRateIntrastate")]],
     ["strGeneralTaxRateInterstate", ["SOAP::SOAPString", XSD::QName.new(nil, "strGeneralTaxRateInterstate")]],
     ["strFoodDrugTaxRateIntrastate", ["SOAP::SOAPString", XSD::QName.new(nil, "strFoodDrugTaxRateIntrastate")]],
     ["strFoodDrugTaxRateInterstate", ["SOAP::SOAPString", XSD::QName.new(nil, "strFoodDrugTaxRateInterstate")]]
   ]
 )

 LiteralRegistry.register(
   :class => TLookUpResults,
   :schema_ns => "urn:JurisLookup",
   :schema_type => "TLookUpResults",
   :schema_qualified => false,
   :schema_element => [
     ["intReturnCode", ["SOAP::SOAPInt", XSD::QName.new(nil, "intReturnCode")]],
     ["strReturnShortDesc", ["SOAP::SOAPString", XSD::QName.new(nil, "strReturnShortDesc")]],
     ["strConfirmationNum", ["SOAP::SOAPString", XSD::QName.new(nil, "strConfirmationNum")]],
     ["strEventTimeStamp", ["SOAP::SOAPString", XSD::QName.new(nil, "strEventTimeStamp")]],
     ["fIPSRecordList", ["TArrayofFIPSRecord", XSD::QName.new(nil, "FIPSRecordList")]]
   ]
 )

 LiteralRegistry.register(
   :class => TArrayofFIPSRecord,
   :schema_ns => "urn:JurisLookup",
   :schema_type => "TArrayofFIPSRecord",
   :schema_element => [
     ["item", ["TFIPSRecord", XSD::QName.new(nil, "item")]]
   ]
 )

 LiteralRegistry.register(
   :class => TFIPSRecord,
   :schema_ns => "urn:JurisLookup",
   :schema_type => "TFIPSRecord",
   :schema_qualified => false,
   :schema_element => [
     ["intState", ["SOAP::SOAPInt", XSD::QName.new(nil, "intState")]],
     ["strJurisdictionType", ["SOAP::SOAPString", XSD::QName.new(nil, "strJurisdictionType")]],
     ["strCompositeSER", ["SOAP::SOAPString", XSD::QName.new(nil, "strCompositeSER")]],
     ["intJurisdictionFIPS", ["SOAP::SOAPInt", XSD::QName.new(nil, "intJurisdictionFIPS")]],
     ["strGeneralTaxRateIntrastate", ["SOAP::SOAPString", XSD::QName.new(nil, "strGeneralTaxRateIntrastate")]],
     ["strGeneralTaxRateInterstate", ["SOAP::SOAPString", XSD::QName.new(nil, "strGeneralTaxRateInterstate")]],
     ["strFoodDrugTaxRateIntrastate", ["SOAP::SOAPString", XSD::QName.new(nil, "strFoodDrugTaxRateIntrastate")]],
     ["strFoodDrugTaxRateInterstate", ["SOAP::SOAPString", XSD::QName.new(nil, "strFoodDrugTaxRateInterstate")]]
   ]
 )
end
##################################################

2007-07-28 05:20 PM

Life is too short for this ...
Hi - I don't think the problem is related to this.  As I mentioned above - there are many reasons for the 'expected X to define Y' error.  Essentially, your app is not able to load the correct rb file.  You can also check the permissions to see if anything is messed up there.  Have support take a look if you continue to have trouble.

2007-07-29 02:13 AM

Is there a production mode equivalent of logger.debug?
I have found that logger.debug does not show up in production.log like it does in development.log.
Jee

2007-07-31 10:26 AM

Life is too short for this ...
Yes.  'Logger.info'
Or you can set
config.log_level=:debug in your environment.rb file.  By default log_level is :info in production and :debug in development (so :debug doesn't show up in production mode)

2007-07-31 01:09 PM

Hooray,
I finally got this fixed.

Add the following lines:
require 'rubygems'
gem 'soap4r'

at the very top of environment.rb.

That is probably obvious to experienced RoR developers, but for those of us who are not ...
:)
Jee

2007-08-29 03:12 PM

Life is too short for this ...

Hello Guest! In order to post you must be an active client with us, please log in or sign up.