Hi all, I''m trying to validate a data field. I''ve added ''validate_presence_of :name'' to the record model, but when I try to create a record i get an error complaining that it can''t find data from another table that also is updated on that page. Let me explain further, On my ''record'' update page, I have data from another table displayed. When i try to validate the ''record'' data, an error is thrown complaining that it can''t find the data from the other table? Any insight would be appreciated, Ice -- Posted via http://www.ruby-forum.com/.
On 7/6/06, Ice <mdalsant@gmail.com> wrote:> Hi all, > > I''m trying to validate a data field. > > I''ve added ''validate_presence_of :name'' to the record model, but when I > try to create a record i get an error complaining that it can''t find > data from another table that also is updated on that page. > > Let me explain further, > > On my ''record'' update page, I have data from another table displayed. > When i try to validate the ''record'' data, an error is thrown complaining > that it can''t find the data from the other table? > > Any insight would be appreciated, > > IceIf it''s not sensitive I think the list could use a little bit of code and maybe a database schema for the tables. And especially the exact error you''re getting. Cheers, Chuck Vose
> If it''s not sensitive I think the list could use a little bit of code > and maybe a database schema for the tables. And especially the exact > error you''re getting. > > Cheers, > Chuck VoseHi Chuck, Sorry for the lack of detail... here''s what my situation is. I''ve added ----recordModel----------- validates_presence_of :name ----recordController def new @record = Record.new @product = Product.find(@params[''product_id'']) end def create @record = Record.new(@params[''record'']) @record.save end ----newRecord.rhtml New record for <%= @product.number %> <form action = "../record/create" method = ''post''> Enter in record name <input id="record_name" name="record[name]" type = ''text'' value = ""/> <input type = "submit" value = "create" /> </form> -----error complains:------------ You have a nil object when you didn''t expect it! The error occured while evaluating nil.number (which is in reference to product.nubmber) Please let me know if you need more detail Mike -- Posted via http://www.ruby-forum.com/.