I was having a problem using the active scaffold's subform when creating child objects in the create form. I had a class ClassSections that has_one Course. When I clicked "create new" in the AS scaffold I had the opportunity to enter a new Course in the Course subform that shows on the ClassSections's create form. However, when I saved it , it returned an error telling me that "Course can't be null". I was surpirsed since I could choose an existing Course but not create one from that form.
After some time, I discovered that the culprit was that I had a validation in the ClassSections class to prevent the course_id to be null (validates_nullability_of :course) and in the RDBMS I had also a NOT NULL constraint in the foreign key. I disabled both constrains (in the class and in the RDBMS) and now it works.
The lesson learned: In Active scaffold, if you want to be able to create objects for the has_one relationship in the Create form's has_one subform, you must disable any validation or contraint that prevents the foreign key to be null.
The following Powershell script will convert a batch of JPEG files to TIFF format: #This Code is released under MIT license [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") $files_folder = 'C:\path-where-your-jpg-files-are\' $pdfs = get-childitem $files_folder -recurse | where {$_.Extension -match "jpg"} foreach($pdf in $pdfs) { $picture = [System.Drawing.Bitmap]::FromFile( $pdf.FullName ) $tiff = $pdf.FullName.replace('.PDF','').replace('.pdf','').replace('.jpg','').replace('.JPG','') + '.tiff' $picture.Save($tiff) }
Comments