Hi all, I have some problems inserting data into a legacy table. the key field of this table is a field named CIN which is a varchar(15). when I try insert into this table using a form (generated by the scaffold generator) I get this Error : _____________________________________________________________________ undefined method `CIN_before_type_cast' for #<Candidat:0x370d8c8> | | Extracted source (around line #6): | | 3: <!--[form:candidat]--> | 4: | 5: <p><label for="candidat_CIN">CIN</label><br/> | 6: <%= text_field 'candidat', 'CIN' %></p> | 7: | 8: <p><label for="candidat_NOM_CANDIDAT">Nom</label><br/> | 9: <%= text_field 'candidat', 'NOM_CANDIDAT' %></p> | _____________________________________________________________________| Then I added the following methods to my Model (Candidat): _____________________________________________________________________ | def CIN_before_type_cast | read_attribute(:CIN) | end | | def CIN_before_type_cast=(input) | write_attribute(:CIN, input) | end | _____________________________________________________________________| when I retry to insert using the same form I get this error message : - CIN cannot be blank Please help, I'm a beginner and still discovering Rails and Ruby
on 2006-05-22 21:16
on 2006-05-22 21:53
Hi, you'll need to update this database field within your table to allow nulls. This should do the job. Peace, -Conrad
on 2006-05-22 22:11
Conrad T. wrote: > Hi, you'll need to update this database field within your table to allow > nulls. This should do the job. > > Peace, > > -Conrad Thank your for the reply, I can't set the field to allow because it's the table primary key. I even tried to do so but Mysql ignored my attempt to update this field. Any idea ?