This project is archived and is in readonly mode.
"warning: default 'to_a' will be obsolete" from method_missing in association_proxy
Reported by Greg Hazel | July 16th, 2010 @ 01:27 AM
Similar to #2121, I get a lot of these:
.../gems/activerecord-2.3.8/lib/active_record/associations/association_proxy.rb:215: warning: default `to_a' will be obsolete
the culprit seems to be the method_missing system. The line of code which kicks things off is:
.../gems/ar-extensions-0.9.2/lib/ar-extensions/extensions.rb:259:in `process'
values = [*val]
That splat is translated to :to_a for method_missing, so when
association_proxy calls @target.send(method, *args,
&block)
, the warning is thrown.
So, I'm not sure where the fix should go, but spamming my log file is certainly not the right solution.
Comments and changes to this ticket
-
David Trasbo August 1st, 2010 @ 02:20 PM
- Assigned user set to Rohit Arondekar
What you're seeing is a warning Rails throws because of some code in an third party gem. The fix should go in that gem - there's a reason Rails throws the warning, and it's there to remind people to fix their code.
This can be closed.
-
Greg Hazel August 1st, 2010 @ 02:26 PM
Fix their code to say what? They are not using Object#to_a, they are using [*val].
-
Rohit Arondekar August 1st, 2010 @ 02:32 PM
- Importance changed from to Low
It certainly looks like an issue of ar-extensions. Can you try opening a ticket/issue there? :)
-
Rohit Arondekar August 1st, 2010 @ 02:32 PM
- State changed from new to invalid
-
Greg Hazel August 1st, 2010 @ 02:33 PM
And what should I request that they do differently? Rails is throwing a warning about to_a, what is the solution?
-
Greg Hazel August 1st, 2010 @ 02:34 PM
FYI, it was filed 8 months ago, with no response: http://github.com/zdennis/ar-extensions/issues#issue/6
It's not clear what other code should do here. Rails should remove the warning, or make some indication about alternatives.
-
Rohit Arondekar August 1st, 2010 @ 02:36 PM
- State changed from invalid to new
Greg, somebody provided a patch in that ticket: http://github.com/thillerson/ar-extensions/commit/fc0cab906ebc3766f... The patch is for ar-extensions. Can you try commenting on that ticket and see if the author responds?
-
Greg Hazel August 1st, 2010 @ 02:45 PM
Well, we'll see. The developer obvious has not done anything with the extension for some time.
The to_a function is (maybe, eventually) being obsoleted by Ruby -- I don't see why Rails needs to try to enforce that by spamming my logs.
-
Rohit Arondekar August 1st, 2010 @ 02:56 PM
Can you try applying that patch manually to see if it fixes the issue?
-
David Trasbo August 1st, 2010 @ 03:14 PM
Greg,
to_a
is not obsoleted by Ruby, that's not what the warning says. As I said that warning can't just be removed because you don't want your logs spammed because of code in another gem. There's a reason this warning is thrown.Yes,
to_a
is called implicitly here, but that doesn't matter. Rails doesn't know better. -
Greg Hazel August 1st, 2010 @ 09:15 PM
What is the reason the warning is thrown? It is not informative to me.
-
David Trasbo September 9th, 2010 @ 01:29 PM
The warning is thrown because calling
to_a
on an instance ofAssociationProxy
will be obsolete just like the warning says. Once again: There's a perfectly good technical reason this warning is thrown, and it's there to remind people to fix there code - removing a warning doesn't fix the cause of the warning.Please do close this ticket.
-
Rohit Arondekar September 9th, 2010 @ 01:43 PM
- State changed from new to invalid
-
Greg Hazel September 9th, 2010 @ 10:48 PM
Can you suggest how the issue should be solved? The code which generates this error is not even using to_a, it's using the splat operator.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>