portablemind/Knitkit-CMS — Issue #10: Content and Content Versions created_by_id
Author: gspederson
Created: 2012-03-07 15:59:50+00:00
State: open
Labels: defect

The created_by_id field of contents and content_versions tables should probably be set to current_user.id during import of a site.

While working with an imported site I got this error:

ActiveRecord::RecordNotFound (Couldn't find User without an ID):
lib/compass_agile_enterprise/knitkit/app/models/content.rb:131:in `assign_attribute_on_save'

Which was the result of the created_by_id being NULL in contents and content_versions tables.

I believe this error would also happen if the value exported didn't match an active user. For example the Content record was created by user 6, and the site was exported then imported to another server that didn't have a user 6. That is why I believe the correct value should be current_user.id, since technically speaking the current_user importing the site is the new content creator.