Properly saving data with ActiveRecord
Moved image processing function into a helper class