Hello everybody! Suppose I create a model like the following: class Email < ActiveRecord::Base validates_presence_of :name end Is it possible to know the presence of "validates_presence_of" from a view? I imagine a helper in the view that automatically shows a "*" if the field passed as a parameter is compulsory... Thanks, Silvano -- . . . Silvano Stralla . . . e-mail: silvano.stralla-4RvtM1ply7U1GQ1Ptb7lUw@public.gmane.org site: http://www.sistrall.it flog: http://www.sistrall.it/flog
silvano.stralla wrote:> Hello everybody! > > Suppose I create a model like the following: > > class Email < ActiveRecord::Base > validates_presence_of :name > end > > Is it possible to know the presence of "validates_presence_of" from a > view? > I imagine a helper in the view that automatically shows a "*" if the > field passed as a parameter is compulsory... > > Thanks, > Silvano > > > -- > . . . Silvano Stralla . . . > e-mail: silvano.stralla-4RvtM1ply7U1GQ1Ptb7lUw@public.gmane.org > site: http://www.sistrall.it > flog: http://www.sistrall.it/flogI assume that you are trying to show the user the input field that has been rejected? If so, the scaffold code generated will do this (it puts a big box around the rejected field(s)). Generate a dummy project and a scaffold and look how they do it there. Rick -- Posted via http://www.ruby-forum.com/.
I think he wants to automatically show during the initial display of the form which fields will be validated and required. Thanks, Eugene Cook -----Original Message----- From: Rick Williams [mailto:willirl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org] Sent: Wednesday, November 16, 2005 11:30 AM To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org Subject: [Rails] Re: Automatically show "*" if a field is required silvano.stralla wrote:> Hello everybody! > > Suppose I create a model like the following: > > class Email < ActiveRecord::Base > validates_presence_of :name > end > > Is it possible to know the presence of "validates_presence_of" from a > view? > I imagine a helper in the view that automatically shows a "*" if the > field passed as a parameter is compulsory... > > Thanks, > Silvano > > > -- > . . . Silvano Stralla . . . > e-mail: silvano.stralla-4RvtM1ply7U1GQ1Ptb7lUw@public.gmane.org > site: http://www.sistrall.it > flog: http://www.sistrall.it/flogI assume that you are trying to show the user the input field that has been rejected? If so, the scaffold code generated will do this (it puts a big box around the rejected field(s)). Generate a dummy project and a scaffold and look how they do it there. Rick -- Posted via http://www.ruby-forum.com/.
Rick Williams <willirl@...> writes:> I assume that you are trying to show the user the input field that has > been rejected? If so, the scaffold code generated will do this (it puts > a big box around the rejected field(s)). Generate a dummy project and a > scaffold and look how they do it there.I can''t use scaffold (because I need more complex form) and I don''t like the way it shows errors: I want, for example, write error messages beside fields. I want to show if a field is required during the initial display of the form: more generally, I want have access from the view to the validation schema of the model. Is it possible? Thanks, Silvano