Hi Friends I have two below classes class Employee< ActiveRecord::Base validates_presence_of :name, ........ end other class AuditObserver < ActiveRecord::Observer observe Employee ........ end But when we are creating the Employee record form create view All predefined error messages are twice Means validation error # Name can''t be blank # Name can''t be blank Could please give any advice on it ? Why the error messages are Double? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Are you calling require ''employee'' anywhere? If so you are likely causing the model to load twice which causes duplicate errors because the validates_presence_of method gets called twice. Aaron --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 17, 8:51 am, Aaron <baldw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you calling require ''employee'' anywhere? If so you are likely > causing the model to load twice which causes duplicate errors because > the validates_presence_of method gets called twice.But #require shouldn''t load employee twice, unless it''s given two different paths, right? ///ark --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
I had the exact same problem as described in the original post. I tracked it down to some explicit require statements I had at the top of one of my models. When I removed the requires the double error messages went away. You are right that "require" will only load the file once. But if you load the class another way calling "require" will load it again. Aaron On Jan 17, 11:04 am, Mark Wilden <m...-OCn100epQuBBDgjK7y7TUQ@public.gmane.org> wrote:> On Jan 17, 8:51 am, Aaron <baldw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Are you calling require ''employee'' anywhere? If so you are likely > > causing the model to load twice which causes duplicate errors because > > the validates_presence_of method gets called twice. > > But #require shouldn''t load employee twice, unless it''s given two > different paths, right? > > ///ark--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
I didn''t call require in any models But I have called require in employee controller Is that any problem? But the error messages twice in only testing , production Error messages are fine in development mode -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ash.christopher wrote:> I am having the same issue. I do not have any extra requires. Has > anyone found a solution to this issue? I am using the basic > scaffolding generated by rails. > > On Jan 17, 7:18�am, Karni Karni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>try production mode? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org 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 -~----------~----~----~----~------~----~------~--~---
Karni Karni wrote:> I didn''t call require in any models > > But I have called require in employee controller > > Is that any problem? > > But the error messages twice in only testing , production > Error messages are fine in development modemaybe calling ''require_dependency'' instead of ''require'' would help? -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks a lott *Roger Pack* ! Including via require_dependency rather than require does solve the mystery..:) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6bd3d153-2662-4dcd-bfc1-43f35f54cc1c%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.