Hi,
I have following models
class User < ActiveRecord::Base
has_many :addresses, :as =>:addressee, :dependent => :destroy
accepts_nested_attributes_for :addresses, :allow_destroy => true
end
class Address < ActiveRecord::Base
belongs_to :addressee, :polymorphic => true
validates_presence_of :address1, :maximum => 50,:message =>
"Address1
cannot be blank."
validates_presence_of :city,:message => "City cannot be blank."
validates_presence_of :state,:message => "State cannot be
blank."
validates_presence_of :zipcode,:message => "Zip Code cannot be
blank."
validates_presence_of :country,:message => "Country cannot be
blank."
end
also in my environment file(environment.rb)
#Customize errors
config.action_view.field_error_proc = Proc.new do |html_tag, instance|
if instance.error_message.kind_of?(Array)
%{<div class="input">#{html_tag}</div><div
class="error">•#{[instance.error_message].join(''<br/>•'')}</div>}
else
%{<div class="input">#{html_tag}</div><div
class="error">•#{[instance.error_message].flatten.first}</div>}
end
end
when i am creating user it will give me all model validations error
properly.
but when i am updating user it only show user model validations. for
addresses if any error is there or it is not showing that message inside
my form. i am not understanding why this is happening? anybody can give
me how can i debug this problem?
i have used field_error_proc for customizing my error messages(show
error for field level)
Please help me out what''s going wrong?
--
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
http://groups.google.com/group/rubyonrails-talk?hl=en.