Please ask this question on the rubyonrails-talk mailing list. This list is 
reserved for core talk.

-- 
Ryan Bigg

On Tuesday, 1 March 2011 at 2:06 AM, niklas | brueckenschlaeger wrote: 
> Today I tried to remove (actually overwrite) a validation from a model,
> from within a plugin.
> 
> This was the original validation:
>  validates_length_of :login, :maximum => 30
> 
> This was the only code I could come up with to replace it:
> 
>  def self.included(base)
>  base.class_eval do
>  @validate_callbacks.delete_if { |callback|
>  begin
>  # Sorry, only way to remove validation...
>  # Probably tightly coupled to AR 2.3.5
>  (callback.method.respond_to?(:binding)) &&
>  (eval("attrs", callback.method.binding).first == :login) &&
>  (callback.options[:maximum] == 30)
>  rescue NameError
>  false
>  end
>  }
> 
>  validates_length_of(:login, :maximum => 75)
>  end
> 
> Now in this case I could also have changed the options[:maximum] on the
> callback, but either way - is there a cleaner way?
> 
>  -- niklas
> 

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

Reply via email to