Ruby on Rails Friday, December 31, 2010

Doh! Thanks, that was the problem, obviously.

On Dec 30, 6:12 pm, Philip Hallstrom <phi...@pjkh.com> wrote:
> 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
>
>
>
>
>
>
>
>
>
> > 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