
Calling deprecated Resource#update_attributes raises an error rather than outputting a deprecation warning
Reported by Greg Campbell | December 16th, 2009 @ 12:17 PM | in 1.0.0
It appears that the error is coming from the deprecation routine for update_attributes. See below.
require 'rubygems'
require 'dm-core'
DataMapper.setup(:default, 'sqlite3::memory:')
class Car
include DataMapper::Resource
property :id, Serial
property :make, String
property :model, String
end
DataMapper.auto_migrate!
car = Car.create(:make => "Toyota", :model => "Prius")
# The next line should output a deprecation warning, but instead raises a NoMethodError
car.update_attributes(:make => "Honda", :model => "Accord")
Comments and changes to this ticket
-
Greg Campbell December 16th, 2009 @ 12:57 PM
- Tag changed from deprecation, update_attributes to deprecation, regression, update_attributes
Tagging as a regression, as this appears to have worked in 0.10.1.
-
-
MarkMT December 19th, 2009 @ 09:46 AM
I'm seeing the same problem. The issue seems to be with the line
caller = caller[0]
in update_attributes. The exception claims that [] is being called on nil, but I can't see that it makes sense that caller would return nil. As a sanity check I printed caller.inspect and caller[0] on the line preceding and don't see a problem.
However the problem seems to be with the choice of 'caller' as the local variable name. I just changed it to 'ccaller' and everything works fine. I guess there is some subtlety (or just ignorance on my part) with how ruby parses and executes that statement - it seems that the symbol is replaced before the rvalue is evaluated.
-
Dan Kubb (dkubb) February 5th, 2010 @ 02:55 AM
- State changed from new to resolved
- Assigned user set to Dan Kubb (dkubb)
- Milestone set to 1.0.0
-
Dan Kubb (dkubb) February 5th, 2010 @ 02:56 AM
(from [2df32a6f01d60e9d58ba6ab62212438617283fa7]) Fixed error in Resource#update_attributes
- This method will be removed in the next release 0.10.4, so it is advisable to stop using it. This fix will be included in the 0.10.3 release
[#1156 state:resolved] http://github.com/datamapper/dm-core/commit/2df32a6f01d60e9d58ba6ab...
-
Dan Kubb (dkubb) February 5th, 2010 @ 02:56 AM
I have resolved this ticket, although I would strongly recommend not using Resource#update_attributes after the 0.10.3 release. It will likely be removed for 0.10.4.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Referenced by
-
1156 Calling deprecated Resource#update_attributes raises an error rather than outputting a deprecation warning [#1156 state:resolved] http://github.com/datamapper/dm-c...