1

Calling method "polymorphic_url" in controller or template with array as argument, like:

polymorphic_url([@agency, @agency.divisions.first])

causing ArgumentError exception named "recursive array join". Any suggestions?

I can reproduce this exception with any of models:

@e = Estate.where(:booklets => {'$exists' => true}).first
@b = @e.booklets.first
polymorphic_url [@e,@b]

rails 3.2.3, 3.2.4, 3.2.5

ruby 1.9.2, 1.9.3

4
  • I have the same error on rails 3.2.3 with link_to. Error appeared after bundle update today morning. I'm using mongo and mongoid and they were broken because of latest update, but I've already set older versions in Gemfile. Not sure if it may cause problem... But I didn't change anything in models, views or controllers. I've only tried to install jquery gem and make an update. Commented Jun 6, 2012 at 12:15
  • Im using mongoid too, and probably problem appear after upgrading to 2.4.10. Im shure, problem the same, becouse "link_to" calling "polymorphic_url" to build up url. Commented Jun 6, 2012 at 12:26
  • Now im force to use mongoid '2.4.8', which works ok in production, but problem doesn't solved. Commented Jun 6, 2012 at 12:44
  • Ok, my problem is solved by updating to rails 3.2.5 from 3.2.3 in Gemfile. Thanks everyone :) Commented Jun 6, 2012 at 13:02

3 Answers 3

2

You can create your Error with an Array which contains a reference to itself:

a = []
a<<a
a.join #ArgumentError: recursive array join

I'm guessing here, but if divisions points to the same array as @agencie( for instance an agency being it's own division) I can imagine something like above happening. May be it does not have anything to do with updates but with the data.

Sign up to request clarification or add additional context in comments.

Comments

0

I believe you are misusing it. According to APIDock, here are some examples of polymorphic_url use:

# calls post_url(post)
polymorphic_url(post) # => "http://example.com/posts/1"
polymorphic_url([blog, post]) # => "http://example.com/blogs/1/posts/1"
polymorphic_url([:admin, blog, post]) # => "http://example.com/admin/blogs/1/posts/1"
polymorphic_url([user, :blog, post]) # => "http://example.com/users/1/blog/posts/1"
polymorphic_url(Comment) # => "http://example.com/comments"

So maybe you should use:

polymorphic_url([@agency, @division])

Comments

-1

Im solve this issue by forcing application to use bson '1.6.2' https://github.com/mongoid/mongoid/issues/2069

1 Comment

By the way, I've updated to bson 1.6.4 in about a couple of hours. Seems it was released today. And it works fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.