change unless !blank? to if blank? in get_primary_key