Prashant Tiwari
2006-Mar-14 07:13 UTC
[Rails] Can anybody tell me step by step how validate data on form?
Hi, I am new to ROR. I have created a form with foru fields in ROR. Now its working fine for all CRUD operations. But I want to validate data on form for "validates_presence_of" validation. How to do this? I tried it by putting line "validates_presence_of :description" . But its not working. Its throws error like "undefined method `each'' for nil:NilClass" Also what is ":description" in the "validates_presence_of :description" ? Is it a database column name or name of the field (textbox) on my form that is responsible for holding value of description field? Please help me. Thanks in advaance. Prash -- Posted via http://www.ruby-forum.com/.
David Ang
2006-Mar-14 07:58 UTC
[Rails] Re: Can anybody tell me step by step how validate data on fo
hi there, there''s a nice tutorial about validation somewhere on day 4 i think: http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf -david Prashant Tiwari wrote:> Hi, > > I am new to ROR. I have created a form with foru fields in ROR. Now its > working fine for all CRUD operations. But I want to validate data on > form for "validates_presence_of" validation. How to do this? > I tried it by putting line "validates_presence_of :description" . But > its not working. Its throws error like "undefined method `each'' for > nil:NilClass" > Also what is ":description" in the "validates_presence_of :description" > ? Is it a database column name or name of the field (textbox) on my form > that is responsible for holding value of description field? > > Please help me. > > Thanks in advaance. > Prash-- Posted via http://www.ruby-forum.com/.
Prashant Tiwari
2006-Mar-14 08:28 UTC
[Rails] Re: Can anybody tell me step by step how validate data on fo
Hi, I already tried the steps mentioned in the "http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf". But not working. I m getting above error. Please help me. I am trying from last 2 days. Thanx in advance. Prash David Ang wrote:> hi there, > > there''s a nice tutorial about validation somewhere on day 4 i think: > > http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf > > -david > > Prashant Tiwari wrote: >> Hi, >> >> I am new to ROR. I have created a form with foru fields in ROR. Now its >> working fine for all CRUD operations. But I want to validate data on >> form for "validates_presence_of" validation. How to do this? >> I tried it by putting line "validates_presence_of :description" . But >> its not working. Its throws error like "undefined method `each'' for >> nil:NilClass" >> Also what is ":description" in the "validates_presence_of :description" >> ? Is it a database column name or name of the field (textbox) on my form >> that is responsible for holding value of description field? >> >> Please help me. >> >> Thanks in advaance. >> Prash-- Posted via http://www.ruby-forum.com/.
David Mitchell
2006-Mar-14 12:06 UTC
[Rails] Re: Can anybody tell me step by step how validate data on fo
With "validates_presence_of :description", "description" refers to a field in your table. It goes in the model for one of your tables; the "description" field will be in that table. When you go to create or update a record in that table, the "description" field has to be non-null. The "undefined method ''each'' for nil::NilClass" error is saying that you''re trying to do an "each" iteration on an object that has a nil value - you can''t do an ''each'' on it because nil objects don''t have subcomponents. Check for a typo in your code somewhere; if that doesn''t help, use breakpoints to pause things at an appropriate spot so you can check the values of your variables. Regards Dave M. On 14/03/06, Prashant Tiwari <tiwari_p_k@yahoo.com> wrote:> Hi, > I already tried the steps mentioned in the > "http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf". But not > working. I m getting above error. Please help me. I am trying from last > 2 days. > Thanx in advance. > Prash > > David Ang wrote: > > hi there, > > > > there''s a nice tutorial about validation somewhere on day 4 i think: > > > > http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf > > > > -david > > > > Prashant Tiwari wrote: > >> Hi, > >> > >> I am new to ROR. I have created a form with foru fields in ROR. Now its > >> working fine for all CRUD operations. But I want to validate data on > >> form for "validates_presence_of" validation. How to do this? > >> I tried it by putting line "validates_presence_of :description" . But > >> its not working. Its throws error like "undefined method `each'' for > >> nil:NilClass" > >> Also what is ":description" in the "validates_presence_of :description" > >> ? Is it a database column name or name of the field (textbox) on my form > >> that is responsible for holding value of description field? > >> > >> Please help me. > >> > >> Thanks in advaance. > >> Prash > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >