How about combining these three lines:
mediaobject.permalink = context[:media_object].delete(:permalink)