Ruby on Rails Thursday, December 30, 2010

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment