Re: Overriding

Stefano Benatti
Thu, 13 May 2010 21:29:43 -0000

It needs a little tweak to make this work on rails 3, since it now
protects all strings against XSS attacks(i.e. html escapes them).

The following works:
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
''''.html_safe
<< html_tag <<
''''.html_safe
end

Obs.: dunno if there isn''t a better way of doing this on rails 3.

Marcel Molina Jr. wrote:
> On Sat, Mar 25, 2006 at 01:22:05PM +1100, Dan Harper wrote:
>> Does anyone know how to override the <div
class="fieldWithErrors">
>> behaviour when a form field is incorrect?
>
> This is what ActionView does:
>
> module ActionView
>   class Base
>     @@field_error_proc = Proc.new{ |html_tag, instance| "<div
> class=\"fieldWithErrors\">#{html_tag} " }
>     cattr_accessor :field_error_proc
>   end
> end
>
> You can set your own Proc. For example, in your config/environment.rb:
>
> ActionView::Base.field_error_proc = Proc.new {|html_tag, instance|
> %(<span
class="field-with-errors">#{html_tag})}
>
> marcel

--
Posted via http://www.ruby-forum.com/.

--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at