Logic from controllers moved to attachment model