Hi,
I would like to ask how to override validation functionality in RoR?
In active_record_helper.rb class there is “hardcoded” default html
generated durning validation.
If I will use
{code:ruby}
validates_presence_of :summary, :description
{code}
in my model class, there is html generated:
{code:html}
2 errors
prohibited this issue from being saved
There were problems with
the following fields:
- Summary can't be
blank
- Description can't be blank
{code}
I would like to change standard functionality and just have validation
message next to input field.
What is the best approach to do this?
Best regards,
Tomek
Hi,
It is me again. What I have done so far…
In the environment.rb I have added lines
{code:ruby}
ActionView::Base.field_error_proc = Proc.new {|html_tag, instance|
%(
#{html_tag}
)}
ActionView::Base.field_error_proc = Proc.new {|html_tag, instance|
%(
#{html_tag}
)}
module ActionView
module Helpers
module ActiveRecordHelper
def error_messages_for(object_name, options = {})
end
end
end
end
{code}
It ovverides standard functionality. But unfortunatly I don’t know how
to exten field_error_proc to have full validation message.
Best regards,
Tomek