wrong number of arguments (1 for 0) #4

Closed
ghost opened this Issue Jun 25, 2010 · 7 comments

Projects

None yet

1 participant

@ghost
ghost commented Jun 25, 2010

Hi, when I am trying to generate a sitemap with several model it gives me the above error. What I did in my Raketask was simply:
sitemap.add Static
sitemap.add Category
sitemap.add Product
sitemap.add Company

Am I wrong on the syntax? Missing something?

@alexrabarts
Owner

Hi Valentin, can you please provide the full stack trace? Cheers, Alex

@ghost
ghost commented Jun 25, 2010

Hi Alex, sure, here we go:
rake aborted!
wrong number of arguments (1 for 0)
/opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:114:in find_for_sitemap' /opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:114:insend'
/opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:114:in generate' /opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:109:ineach'
/opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:109:in generate' /opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:104:ineach'
/opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:104:in generate' /opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:201:inwith_sitemap'
/opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:86:in generate' /opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:85:ineach'
/opt/local/lib/ruby/gems/1.8/gems/alexrabarts-big_sitemap-0.5.1/lib/big_sitemap.rb:85:in generate' /Users/vjmayr/softwareclick/lib/tasks/sitemap.rake:15 /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/local/bin/rake:19:in `load'
/opt/local/bin/rake:19

@alexrabarts
Owner

Hi Valentin, your find_for_sitemap class methods should take an options hash and preferably be able to handle :limit and :offset in the same way that ActiveRecord's find does. I think that's the problem.

@ghost
ghost commented Jun 25, 2010

But isn' that the one that is coming with the gem? I didn' t change a thing ... Or am I being blind?

@alexrabarts
Owner

Each model needs to provide either an all or find_for_sitemap class method. I'm guessing your Static class doesn't have an ActiveRecord backend, so doesn't have Static#all defined? If so, you need to define either Static#all or Static#find_for_sitemap that returns all instances of the model that you want to include in the sitemap. The gem ought to really have better error handling around this.

@ghost
ghost commented Jun 25, 2010

Hey Alex, thanks so much! I found the problem, I had a find_for_sitemap hidden in my static model which was for a plugin I used ages ago. It's woking great now. Thanks for the fantastic gem! Cheers, Val

@alexrabarts
Owner

Great - no problem, and glad you found the issue :)

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment