Problem with accepts_nested_attributes_for and reject_if

I am trying to get reject_if to work using a method name instead of a
Proc. However I cannot seem to get this to work. A simplified version
of my model code is shown below. The problem is that I keep getting an
“undefined method `call’ for :not_wired?:Symbol” error. I am using
Rails 2.3.4. Can anyone give me an idea of what might be going on
here?

class DeviceConfiguration < ActiveRecord::Base

has_one :obd_configuration
accepts_nested_attributes_for :obd_configuration, :reject_if
=> :not_obd?

has_one :wired_configuration
accepts_nested_attributes_for :wired_configuration, :reject_if
=> :not_wired?

def not_obd?(attrs)
!device_type.name.eql?(“obd”)
end

def not_wired?(attrs)
!device_type.name.eql?(“wired”)
end

end

On Dec 30, 2010, at 3:17 PM, byron appelt wrote:

I am trying to get reject_if to work using a method name instead of a
Proc. However I cannot seem to get this to work. A simplified version
of my model code is shown below. The problem is that I keep getting an
“undefined method `call’ for :not_wired?:Symbol” error. I am using
Rails 2.3.4. Can anyone give me an idea of what might be going on
here?

2.3.4 doesn’t allow a symbol. Proc only. So either upgrade or switch
over to using a Proc…

-philip

Doh! Thanks, that was the problem, obviously.