Hi,
I have a rails (2.3.5) project that has two models that are not
ActiveRecord based - one is called Wiki and another is called WebApi.
I have been using this in the past, and it was working. However,
something I did is now causing ArgumentError to be raised when I call
a class method on WebApi from a Wiki class method. Here is the
relevant code:
wiki.rb
class Wiki
def self.get_url phrase=’’
response = WebApi.format_and_call(WIKIPEDIA_URL, phrase) #error
occurs here
…
end
…
end
web_api.rb
class WebApi
def self.format_and_call url_format_string, phrase)
…
end
end
Here is the error I get:
ArgumentError (wrong number of arguments (0 for 1)):
app/models/wiki.rb:7:in `get_url’
On debugging, i notice that the error is coming from a const_missing
triggered by the attempt to access the WebApi object (it has nothing
to do with the Wikipedia Url constant, which is fine). Here is the
debug session:
/(rdb:18) step
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:
91
if [Object, Kernel].include?(self) || parent == self
(rdb:18) step
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/module/
introspection.rb:31
parent_name ? parent_name.constantize : Object
(rdb:18) step
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/module/
introspection.rb:8
unless defined? @parent_name
(rdb:18) next
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/module/
introspection.rb:9
@parent_name = name =~ /::[^:]+\Z/ ? $`.freeze : nil
(rdb:18) next
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
gems/1.8/gems/actionpack-2.3.5/lib/action_controller/rescue.rb:162
rescue_action(exception)
(rdb:18) exception
#<ArgumentError: wrong number of arguments (0 for 1)>
I had initially named the WebApi class as Web, and thought the problem
may be due to a name collision, but I tried different names, and get
the same problem.
I am quite confused, since this seems fairly simple code, and I don’t
know where to look.
I am using devise, and have delayed_job as well in the project, but
not really using it in this case.
Thanks
Anand