This project is archived and is in readonly mode.
Calling #method on new AR objects
-
fakingfantastic
- No changes were found…
-
Brian Jensen
Hi
The same problem exists in rails 2.3.8. You can even take it a step further and write User.first.method(:email) and it will give you above error.
Best regards
Brian Jensen
@PointMan_ -
Rohit Arondekar
- Importance changed from to Low
Out of curiosity, why would you want to do
u = User.new u.method(:email).callinstead of
u = User.new u.email -
Rainer Blessing
I tried it with 2.3.8 and 2-3-stable and didn't get the error.
If either u.method(:email).call or u.email is called the execution path runs through method_missing and the correct value is returned.
I got the error only in Rails 3 with Ruby 1.8.7 and 1.9.2-head where method_missing is not called by u.method(:email).Rohit I think u.method can be used if the method is determined at runtime. It's prettier than using eval.
-
fakingfantastic
"Rohit I think u.method can be used if the method is determined at runtime. It's prettier than using eval."
Yeah, I'm pretty sure that was the reason it was stumbled upon.
-
Repository
- State changed from new to resolved
(from [066518295032a8e3f3468737337b8c8299442867]) Preserving :include options for hmt association with an order but without conditions [#5262 Calling #method on new AR objects state:resolved] http://github.com/rails/rails/commit/066518295032a8e3f3468737337b8c...